Skip to content

Commit 27dc5cb

Browse files
authored
Merge pull request #2903 from mgxd/maint/pytest
MAINT: avoid deprecation warnings
2 parents 232ac23 + 30950ac commit 27dc5cb

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

nipype/algorithms/tests/test_CompCor.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ def test_compcor_bad_input_shapes(self):
108108
data_file = utils.save_toy_nii(np.zeros(data_shape), 'temp.nii')
109109
interface = CompCor(
110110
realigned_file=data_file, mask_files=self.mask_files[0])
111-
with pytest.raises(ValueError, message="Dimension mismatch"):
112-
interface.run()
111+
with pytest.raises(ValueError):
112+
interface.run() # Dimension mismatch
113113

114114
def test_tcompcor_bad_input_dim(self):
115115
bad_dims = (2, 2, 2)
116116
data_file = utils.save_toy_nii(np.zeros(bad_dims), 'temp.nii')
117117
interface = TCompCor(realigned_file=data_file)
118-
with pytest.raises(ValueError, message='Not a 4D file'):
119-
interface.run()
118+
with pytest.raises(ValueError):
119+
interface.run() # Not a 4D file
120120

121121
def test_tcompcor_merge_intersect_masks(self):
122122
for method in ['union', 'intersect']:
@@ -145,8 +145,8 @@ def test_tcompcor_index_mask(self):
145145
def test_tcompcor_multi_mask_no_index(self):
146146
interface = TCompCor(
147147
realigned_file=self.realigned_file, mask_files=self.mask_files)
148-
with pytest.raises(ValueError, message='more than one mask file'):
149-
interface.run()
148+
with pytest.raises(ValueError):
149+
interface.run() # more than one mask file
150150

151151
def run_cc(self,
152152
ccinterface,

nipype/interfaces/dipy/tracks.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@
2020
if HAVE_DIPY and LooseVersion(dipy_version()) >= LooseVersion('0.15'):
2121

2222
from dipy.workflows.segment import RecoBundlesFlow, LabelsBundlesFlow
23-
from dipy.workflows.tracking import DetTrackPAMFlow
23+
try:
24+
from dipy.workflows.tracking import LocalFiberTrackingPAMFlow as DetTrackFlow
25+
except ImportError: # different name in 0.15
26+
from dipy.workflows.tracking import DetTrackPAMFlow as DetTrackFlow
2427

2528
RecoBundles = dipy_to_nipype_interface("RecoBundles", RecoBundlesFlow)
2629
LabelsBundles = dipy_to_nipype_interface("LabelsBundles",
2730
LabelsBundlesFlow)
2831
DeterministicTracking = dipy_to_nipype_interface("DeterministicTracking",
29-
DetTrackPAMFlow)
32+
DetTrackFlow)
3033

3134
else:
3235
IFLOGGER.info("We advise you to upgrade DIPY version. This upgrade will"

nipype/testing/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
template = funcfile
1717
transfm = funcfile
1818

19-
from . import decorators as dec
19+
from . import decorators
2020
from .utils import package_check, TempFATFS
2121

22-
skipif = dec.skipif
22+
skipif = decorators.dec.skipif
2323

2424

2525
def example_data(infile='functional.nii'):

nipype/testing/decorators.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"""
55
Extend numpy's decorators to use nipype's gui and data labels.
66
"""
7-
8-
from numpy.testing.decorators import knownfailureif, skipif
7+
from numpy.testing import dec
98

109
from nibabel.data import DataError
1110

@@ -81,19 +80,19 @@ def needs_review(msg):
8180
"""
8281

8382
def skip_func(func):
84-
return skipif(True, msg)(func)
83+
return dec.skipif(True, msg)(func)
8584

8685
return skip_func
8786

8887

8988
# Easier version of the numpy knownfailure
9089
def knownfailure(f):
91-
return knownfailureif(True)(f)
90+
return dec.knownfailureif(True)(f)
9291

9392

9493
def if_datasource(ds, msg):
9594
try:
9695
ds.get_filename()
9796
except DataError:
98-
return skipif(True, msg)
97+
return dec.skipif(True, msg)
9998
return lambda f: f

0 commit comments

Comments
 (0)