@@ -719,23 +719,23 @@ def test_recoded_fields(self):
719
719
assert hdr .get_value_label ('slice_code' ) == 'alternating decreasing'
720
720
721
721
def test_general_init (self ):
722
- with clear_and_catch_warnings () as warns :
722
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
723
723
warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
724
724
warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
725
725
warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
726
726
UserWarning )
727
727
super (TestNifti1PairHeader , self ).test_general_init ()
728
728
729
729
def test_from_header (self ):
730
- with clear_and_catch_warnings () as warns :
730
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
731
731
warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
732
732
warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
733
733
warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
734
734
UserWarning )
735
735
super (TestNifti1PairHeader , self ).test_from_header ()
736
736
737
737
def test_data_shape_zooms_affine (self ):
738
- with clear_and_catch_warnings () as warns :
738
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
739
739
warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
740
740
warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
741
741
warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
@@ -1207,7 +1207,7 @@ def test_zooms_edge_cases(self):
1207
1207
img = img_klass (arr , aff )
1208
1208
1209
1209
# Unknown units = 2 warnings
1210
- with clear_and_catch_warnings () as warns :
1210
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1211
1211
warnings .simplefilter ('always' )
1212
1212
assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
1213
1213
(1 , 1 , 1 , 1 ))
@@ -1216,7 +1216,7 @@ def test_zooms_edge_cases(self):
1216
1216
units = 'norm' , raise_unknown = True )
1217
1217
1218
1218
img .header .set_xyzt_units (xyz = 'meter' )
1219
- with clear_and_catch_warnings () as warns :
1219
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1220
1220
warnings .simplefilter ('always' )
1221
1221
assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
1222
1222
(1000 , 1000 , 1000 , 1 ))
@@ -1232,7 +1232,7 @@ def test_zooms_edge_cases(self):
1232
1232
(0.001 , 0.001 , 0.001 , 1 ))
1233
1233
1234
1234
img .header .set_xyzt_units (t = 'sec' )
1235
- with clear_and_catch_warnings () as warns :
1235
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1236
1236
warnings .simplefilter ('always' )
1237
1237
assert_array_equal (img .header .get_zooms (units = 'norm' ),
1238
1238
(1 , 1 , 1 , 1 ))
@@ -1277,7 +1277,7 @@ def test_zooms_edge_cases(self):
1277
1277
1278
1278
# Non-temporal t units are not transformed
1279
1279
img .header .set_zooms ((1 , 1 , 1 , 1.5 ), units = ('mm' , 'ppm' ))
1280
- with clear_and_catch_warnings () as warns :
1280
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1281
1281
warnings .simplefilter ('always' )
1282
1282
assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
1283
1283
(1 , 1 , 1 , 1.5 ))
@@ -1287,7 +1287,7 @@ def test_zooms_edge_cases(self):
1287
1287
1288
1288
# Non-temporal t units are not normalized
1289
1289
img .header .set_zooms ((2 , 2 , 2 , 3.5 ), units = 'norm' )
1290
- with clear_and_catch_warnings () as warns :
1290
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1291
1291
warnings .simplefilter ('always' )
1292
1292
assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
1293
1293
(2 , 2 , 2 , 3.5 ))
@@ -1310,7 +1310,7 @@ def test_zooms_edge_cases(self):
1310
1310
units = 'badparam' )
1311
1311
1312
1312
def test_no_finite_values (self ):
1313
- with clear_and_catch_warnings () as warns :
1313
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1314
1314
warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
1315
1315
warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
1316
1316
warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
0 commit comments