Skip to content

Commit

Permalink
enh: expand test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
oesteban committed Aug 1, 2024
1 parent 8ba34c9 commit 026a10a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 1 addition & 2 deletions nitransforms/resampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ def apply(
else None
)

if njobs is None:
njobs = cpu_count()
njobs = cpu_count() if njobs is None or njobs < 1 else njobs

with ProcessPoolExecutor(max_workers=min(njobs, n_resamplings)) as executor:
results = []
Expand Down
15 changes: 14 additions & 1 deletion nitransforms/tests/test_resampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from nitransforms import nonlinear as nitnl
from nitransforms import manip as nitm
from nitransforms import io
from nitransforms.resampling import apply
from nitransforms.resampling import apply, _apply_volume

RMSE_TOL_LINEAR = 0.09
RMSE_TOL_NONLINEAR = 0.05
Expand Down Expand Up @@ -363,3 +363,16 @@ def test_LinearTransformsMapping_apply(
reference=testdata_path / "sbref.nii.gz",
serialize_nvols=2 if serialize_4d else np.inf,
)


@pytest.mark.parametrize("t", list(range(4)))
def test_apply_helper(monkeypatch, t):
"""Ensure the apply helper function correctly just decorates with index."""
from nitransforms.resampling import ndi

def _retval(*args, **kwargs):
return 1

monkeypatch.setattr(ndi, "map_coordinates", _retval)

assert _apply_volume(t, None, None) == (t, 1)

0 comments on commit 026a10a

Please sign in to comment.