Skip to content

Commit 9fc1bf9

Browse files
committed
geometry: preserve numpy fallback without numba
1 parent 2101955 commit 9fc1bf9

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/pyconfind/geometry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def _place_batch_kernel_python(
161161
_place_batch_kernel_python, cache=True, fastmath=False, error_model="numpy",
162162
)
163163
else: # pragma: no cover
164-
_place_batch_kernel = _place_batch_kernel_python
164+
_place_batch_kernel = _place_batch_numpy
165165

166166

167167
def place_batch(

tests/test_geometry.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66

77
from __future__ import annotations
88

9+
import importlib
10+
import sys
911
from pathlib import Path
1012

1113
import numpy as np
1214
import pytest
1315

16+
import pyconfind.geometry as geometry
1417
from pyconfind.geometry import place_batch, place_one
1518
from pyconfind.pdb import read_structure
1619
from pyconfind.rotamers import place_rotamers
@@ -58,6 +61,17 @@ def test_place_batch_matches_place_one() -> None:
5861
)
5962

6063

64+
def test_place_batch_without_numba_uses_numpy_fallback(monkeypatch: pytest.MonkeyPatch) -> None:
65+
monkeypatch.setitem(sys.modules, "numba", None)
66+
reloaded = importlib.reload(geometry)
67+
try:
68+
assert reloaded._HAS_NUMBA is False
69+
assert reloaded._place_batch_kernel is reloaded._place_batch_numpy
70+
finally:
71+
monkeypatch.undo()
72+
importlib.reload(geometry)
73+
74+
6175
def _parse_rout(path: Path) -> dict[tuple[str, int, str, int], dict[str, np.ndarray]]:
6276
out: dict[tuple[str, int, str, int], dict[str, np.ndarray]] = {}
6377
cur: tuple[str, int, str, int] | None = None

0 commit comments

Comments
 (0)