From 7269ff0fcace6409d316fd4248a1733d221490d8 Mon Sep 17 00:00:00 2001 From: mathiasg Date: Mon, 25 Mar 2019 13:12:46 -0400 Subject: [PATCH 1/3] maint: avoid deprecation warnings --- nipype/algorithms/tests/test_CompCor.py | 9 ++++++--- nipype/testing/__init__.py | 4 ++-- nipype/testing/decorators.py | 9 ++++----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/nipype/algorithms/tests/test_CompCor.py b/nipype/algorithms/tests/test_CompCor.py index 488ad3c960..c31546a48f 100644 --- a/nipype/algorithms/tests/test_CompCor.py +++ b/nipype/algorithms/tests/test_CompCor.py @@ -108,15 +108,17 @@ def test_compcor_bad_input_shapes(self): data_file = utils.save_toy_nii(np.zeros(data_shape), 'temp.nii') interface = CompCor( realigned_file=data_file, mask_files=self.mask_files[0]) - with pytest.raises(ValueError, message="Dimension mismatch"): + with pytest.raises(ValueError): interface.run() + pytest.fail("Dimension mismatch") def test_tcompcor_bad_input_dim(self): bad_dims = (2, 2, 2) data_file = utils.save_toy_nii(np.zeros(bad_dims), 'temp.nii') interface = TCompCor(realigned_file=data_file) - with pytest.raises(ValueError, message='Not a 4D file'): + with pytest.raises(ValueError): interface.run() + pytest.fail("Not a 4D file") def test_tcompcor_merge_intersect_masks(self): for method in ['union', 'intersect']: @@ -145,8 +147,9 @@ def test_tcompcor_index_mask(self): def test_tcompcor_multi_mask_no_index(self): interface = TCompCor( realigned_file=self.realigned_file, mask_files=self.mask_files) - with pytest.raises(ValueError, message='more than one mask file'): + with pytest.raises(ValueError): interface.run() + pytest.fail("more than one mask file") def run_cc(self, ccinterface, diff --git a/nipype/testing/__init__.py b/nipype/testing/__init__.py index 9d57ba87af..2167e7e54a 100644 --- a/nipype/testing/__init__.py +++ b/nipype/testing/__init__.py @@ -16,10 +16,10 @@ template = funcfile transfm = funcfile -from . import decorators as dec +from . import decorators from .utils import package_check, TempFATFS -skipif = dec.skipif +skipif = decorators.dec.skipif def example_data(infile='functional.nii'): diff --git a/nipype/testing/decorators.py b/nipype/testing/decorators.py index f849815700..36c647634c 100644 --- a/nipype/testing/decorators.py +++ b/nipype/testing/decorators.py @@ -4,8 +4,7 @@ """ Extend numpy's decorators to use nipype's gui and data labels. """ - -from numpy.testing.decorators import knownfailureif, skipif +from numpy.testing import dec from nibabel.data import DataError @@ -81,19 +80,19 @@ def needs_review(msg): """ def skip_func(func): - return skipif(True, msg)(func) + return dec.skipif(True, msg)(func) return skip_func # Easier version of the numpy knownfailure def knownfailure(f): - return knownfailureif(True)(f) + return dec.knownfailureif(True)(f) def if_datasource(ds, msg): try: ds.get_filename() except DataError: - return skipif(True, msg) + return dec.skipif(True, msg) return lambda f: f From 55ad341d7676c9f2bf74a03cf0ba347842710bbf Mon Sep 17 00:00:00 2001 From: mathiasg Date: Mon, 25 Mar 2019 13:32:02 -0400 Subject: [PATCH 2/3] maint: remove message --- nipype/algorithms/tests/test_CompCor.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/nipype/algorithms/tests/test_CompCor.py b/nipype/algorithms/tests/test_CompCor.py index c31546a48f..6fdae49f18 100644 --- a/nipype/algorithms/tests/test_CompCor.py +++ b/nipype/algorithms/tests/test_CompCor.py @@ -109,16 +109,14 @@ def test_compcor_bad_input_shapes(self): interface = CompCor( realigned_file=data_file, mask_files=self.mask_files[0]) with pytest.raises(ValueError): - interface.run() - pytest.fail("Dimension mismatch") + interface.run() # Dimension mismatch def test_tcompcor_bad_input_dim(self): bad_dims = (2, 2, 2) data_file = utils.save_toy_nii(np.zeros(bad_dims), 'temp.nii') interface = TCompCor(realigned_file=data_file) with pytest.raises(ValueError): - interface.run() - pytest.fail("Not a 4D file") + interface.run() # Not a 4D file def test_tcompcor_merge_intersect_masks(self): for method in ['union', 'intersect']: @@ -148,8 +146,7 @@ def test_tcompcor_multi_mask_no_index(self): interface = TCompCor( realigned_file=self.realigned_file, mask_files=self.mask_files) with pytest.raises(ValueError): - interface.run() - pytest.fail("more than one mask file") + interface.run() # more than one mask file def run_cc(self, ccinterface, From 30950acdcd73a68d46a1ce45c816f7749a03ccb7 Mon Sep 17 00:00:00 2001 From: mathiasg Date: Wed, 27 Mar 2019 13:26:08 -0400 Subject: [PATCH 3/3] fix: dipy import --- nipype/interfaces/dipy/tracks.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nipype/interfaces/dipy/tracks.py b/nipype/interfaces/dipy/tracks.py index 3643654001..b3d51151e2 100644 --- a/nipype/interfaces/dipy/tracks.py +++ b/nipype/interfaces/dipy/tracks.py @@ -20,13 +20,16 @@ if HAVE_DIPY and LooseVersion(dipy_version()) >= LooseVersion('0.15'): from dipy.workflows.segment import RecoBundlesFlow, LabelsBundlesFlow - from dipy.workflows.tracking import DetTrackPAMFlow + try: + from dipy.workflows.tracking import LocalFiberTrackingPAMFlow as DetTrackFlow + except ImportError: # different name in 0.15 + from dipy.workflows.tracking import DetTrackPAMFlow as DetTrackFlow RecoBundles = dipy_to_nipype_interface("RecoBundles", RecoBundlesFlow) LabelsBundles = dipy_to_nipype_interface("LabelsBundles", LabelsBundlesFlow) DeterministicTracking = dipy_to_nipype_interface("DeterministicTracking", - DetTrackPAMFlow) + DetTrackFlow) else: IFLOGGER.info("We advise you to upgrade DIPY version. This upgrade will"