diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 72eda084..0f8dde3e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: with: fetch-depth: 0 - name: setup Python - uses: actions/setup-python@v6 + uses: actions/setup-python@v7 with: python-version: "3.14" - run: python -m pip install tox diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 5a9ef11c..21d337a8 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -17,7 +17,7 @@ jobs: with: fetch-depth: 0 - name: setup Python - uses: actions/setup-python@v6 + uses: actions/setup-python@v7 with: python-version: "3.14" - name: install dependencies diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 60eddc72..8e7b763c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/checkout@v7 - name: Set up Python - uses: actions/setup-python@v6 + uses: actions/setup-python@v7 with: python-version: "3.14" - run: python -m pip install tox diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 282bb04f..64d484ec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: with: fetch-depth: 0 - name: setup Python - uses: actions/setup-python@v6 + uses: actions/setup-python@v7 with: python-version: "3.14" - run: python -m pip install tox diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 50936bc4..3be2e71e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,7 +26,7 @@ jobs: with: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v6 + uses: actions/setup-python@v7 with: python-version: ${{ matrix.python-version }} - name: activate MSVC (for torch.compile) @@ -55,7 +55,7 @@ jobs: with: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v6 + uses: actions/setup-python@v7 with: python-version: ${{ matrix.python-version }} - name: activate MSVC (for torch.compile / inductor codegen) diff --git a/pyproject.toml b/pyproject.toml index 85b8378c..984fb907 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -107,10 +107,11 @@ line-length = 88 [tool.ruff.lint] # See https://docs.astral.sh/ruff/rules for additional details -extend-select = [ +select = [ "B", # Pyflakes checks (e.g., unused imports, undefined variables) "D", # PEP 257 docstring conventions (e.g., formatting, consistency) "E", # Pycodestyle errors (e.g., indentation, whitespace, syntax) + "F", # Pyflakes (e.g., unused imports, undefined names) "UP", # PyUpgrade rules (e.g., upgrading to modern Python syntax) "I", # Import conventions (e.g., sorting imports, duplicate imports) "SIM", # Simplification suggestions (e.g., refactoring redundant code) diff --git a/src/torchpme/lib/mesh_interpolator.py b/src/torchpme/lib/mesh_interpolator.py index da53ae6e..0f6e6e40 100644 --- a/src/torchpme/lib/mesh_interpolator.py +++ b/src/torchpme/lib/mesh_interpolator.py @@ -1,6 +1,14 @@ import torch +# Runs eagerly: Inductor's CPU backend spuriously raises ZeroDivisionError on +# vectorized `%` with an odd-length divisor (here always 3), see +# https://github.com/pytorch/pytorch/issues/143649 +@torch.compiler.disable +def _mesh_index_remainder(indices: torch.Tensor, ns_mesh: torch.Tensor) -> torch.Tensor: + return indices % ns_mesh + + class MeshInterpolator(torch.nn.Module): """ Class for handling all steps related to interpolations in the context of a mesh @@ -349,7 +357,7 @@ def compute_weights(self, positions: torch.Tensor): # below. indices_to_interpolate = torch.stack( [ - (positions_rel_idx + i) % self.ns_mesh + _mesh_index_remainder(positions_rel_idx + i, self.ns_mesh) for i in range( 1 - (self.interpolation_nodes + 1) // 2, 1 + self.interpolation_nodes // 2, diff --git a/tox.ini b/tox.ini index 31e65772..9e37ea82 100644 --- a/tox.ini +++ b/tox.ini @@ -21,8 +21,7 @@ deps = twine allowlist_externals = bash commands_pre = - bash -c "if [ -e {toxinidir}/dist/*tar.gz ]; then unlink {toxinidir}/dist/*.whl; fi" - bash -c "if [ -e {toxinidir}/dist/*tar.gz ]; then unlink {toxinidir}/dist/*.tar.gz; fi" + bash -c "rm -f {toxinidir}/dist/*.whl {toxinidir}/dist/*.tar.gz" commands = python -m build twine check dist/*.tar.gz dist/*.whl