@@ -716,23 +716,23 @@ def test_recoded_fields(self):
716
716
assert hdr .get_value_label ('slice_code' ) == 'alternating decreasing'
717
717
718
718
def test_general_init (self ):
719
- with clear_and_catch_warnings () as warns :
719
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
720
720
warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
721
721
warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
722
722
warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
723
723
UserWarning )
724
724
super (TestNifti1PairHeader , self ).test_general_init ()
725
725
726
726
def test_from_header (self ):
727
- with clear_and_catch_warnings () as warns :
727
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
728
728
warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
729
729
warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
730
730
warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
731
731
UserWarning )
732
732
super (TestNifti1PairHeader , self ).test_from_header ()
733
733
734
734
def test_data_shape_zooms_affine (self ):
735
- with clear_and_catch_warnings () as warns :
735
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
736
736
warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
737
737
warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
738
738
warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
@@ -1130,7 +1130,7 @@ def test_zooms_edge_cases(self):
1130
1130
img = img_klass (arr , aff )
1131
1131
1132
1132
# Unknown units = 2 warnings
1133
- with clear_and_catch_warnings () as warns :
1133
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1134
1134
warnings .simplefilter ('always' )
1135
1135
assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
1136
1136
(1 , 1 , 1 , 1 ))
@@ -1139,7 +1139,7 @@ def test_zooms_edge_cases(self):
1139
1139
units = 'norm' , raise_unknown = True )
1140
1140
1141
1141
img .header .set_xyzt_units (xyz = 'meter' )
1142
- with clear_and_catch_warnings () as warns :
1142
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1143
1143
warnings .simplefilter ('always' )
1144
1144
assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
1145
1145
(1000 , 1000 , 1000 , 1 ))
@@ -1155,7 +1155,7 @@ def test_zooms_edge_cases(self):
1155
1155
(0.001 , 0.001 , 0.001 , 1 ))
1156
1156
1157
1157
img .header .set_xyzt_units (t = 'sec' )
1158
- with clear_and_catch_warnings () as warns :
1158
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1159
1159
warnings .simplefilter ('always' )
1160
1160
assert_array_equal (img .header .get_zooms (units = 'norm' ),
1161
1161
(1 , 1 , 1 , 1 ))
@@ -1200,7 +1200,7 @@ def test_zooms_edge_cases(self):
1200
1200
1201
1201
# Non-temporal t units are not transformed
1202
1202
img .header .set_zooms ((1 , 1 , 1 , 1.5 ), units = ('mm' , 'ppm' ))
1203
- with clear_and_catch_warnings () as warns :
1203
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1204
1204
warnings .simplefilter ('always' )
1205
1205
assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
1206
1206
(1 , 1 , 1 , 1.5 ))
@@ -1210,7 +1210,7 @@ def test_zooms_edge_cases(self):
1210
1210
1211
1211
# Non-temporal t units are not normalized
1212
1212
img .header .set_zooms ((2 , 2 , 2 , 3.5 ), units = 'norm' )
1213
- with clear_and_catch_warnings () as warns :
1213
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1214
1214
warnings .simplefilter ('always' )
1215
1215
assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
1216
1216
(2 , 2 , 2 , 3.5 ))
@@ -1233,7 +1233,7 @@ def test_zooms_edge_cases(self):
1233
1233
units = 'badparam' )
1234
1234
1235
1235
def test_no_finite_values (self ):
1236
- with clear_and_catch_warnings () as warns :
1236
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1237
1237
warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
1238
1238
warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
1239
1239
warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
0 commit comments