Skip to content

Commit 026a10a

Browse files
committed
enh: expand test coverage
1 parent 8ba34c9 commit 026a10a

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

nitransforms/resampling.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ def apply(
156156
else None
157157
)
158158

159-
if njobs is None:
160-
njobs = cpu_count()
159+
njobs = cpu_count() if njobs is None or njobs < 1 else njobs
161160

162161
with ProcessPoolExecutor(max_workers=min(njobs, n_resamplings)) as executor:
163162
results = []

nitransforms/tests/test_resampling.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from nitransforms import nonlinear as nitnl
1616
from nitransforms import manip as nitm
1717
from nitransforms import io
18-
from nitransforms.resampling import apply
18+
from nitransforms.resampling import apply, _apply_volume
1919

2020
RMSE_TOL_LINEAR = 0.09
2121
RMSE_TOL_NONLINEAR = 0.05
@@ -363,3 +363,16 @@ def test_LinearTransformsMapping_apply(
363363
reference=testdata_path / "sbref.nii.gz",
364364
serialize_nvols=2 if serialize_4d else np.inf,
365365
)
366+
367+
368+
@pytest.mark.parametrize("t", list(range(4)))
369+
def test_apply_helper(monkeypatch, t):
370+
"""Ensure the apply helper function correctly just decorates with index."""
371+
from nitransforms.resampling import ndi
372+
373+
def _retval(*args, **kwargs):
374+
return 1
375+
376+
monkeypatch.setattr(ndi, "map_coordinates", _retval)
377+
378+
assert _apply_volume(t, None, None) == (t, 1)

0 commit comments

Comments
 (0)