@@ -708,23 +708,23 @@ def test_recoded_fields(self):
708
708
'alternating decreasing' )
709
709
710
710
def test_general_init (self ):
711
- with clear_and_catch_warnings () as warns :
711
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
712
712
warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
713
713
warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
714
714
warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
715
715
UserWarning )
716
716
super (TestNifti1PairHeader , self ).test_general_init ()
717
717
718
718
def test_from_header (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_from_header ()
725
725
726
726
def test_data_shape_zooms_affine (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' ,
@@ -1118,7 +1118,7 @@ def test_zooms_edge_cases(self):
1118
1118
img = img_klass (arr , aff )
1119
1119
1120
1120
# Unknown units = 2 warnings
1121
- with clear_and_catch_warnings () as warns :
1121
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1122
1122
warnings .simplefilter ('always' )
1123
1123
assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
1124
1124
(1 , 1 , 1 , 1 ))
@@ -1127,7 +1127,7 @@ def test_zooms_edge_cases(self):
1127
1127
units = 'norm' , raise_unknown = True )
1128
1128
1129
1129
img .header .set_xyzt_units (xyz = 'meter' )
1130
- with clear_and_catch_warnings () as warns :
1130
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1131
1131
warnings .simplefilter ('always' )
1132
1132
assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
1133
1133
(1000 , 1000 , 1000 , 1 ))
@@ -1143,7 +1143,7 @@ def test_zooms_edge_cases(self):
1143
1143
(0.001 , 0.001 , 0.001 , 1 ))
1144
1144
1145
1145
img .header .set_xyzt_units (t = 'sec' )
1146
- with clear_and_catch_warnings () as warns :
1146
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1147
1147
warnings .simplefilter ('always' )
1148
1148
assert_array_equal (img .header .get_zooms (units = 'norm' ),
1149
1149
(1 , 1 , 1 , 1 ))
@@ -1188,7 +1188,7 @@ def test_zooms_edge_cases(self):
1188
1188
1189
1189
# Non-temporal t units are not transformed
1190
1190
img .header .set_zooms ((1 , 1 , 1 , 1.5 ), units = ('mm' , 'ppm' ))
1191
- with clear_and_catch_warnings () as warns :
1191
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1192
1192
warnings .simplefilter ('always' )
1193
1193
assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
1194
1194
(1 , 1 , 1 , 1.5 ))
@@ -1198,7 +1198,7 @@ def test_zooms_edge_cases(self):
1198
1198
1199
1199
# Non-temporal t units are not normalized
1200
1200
img .header .set_zooms ((2 , 2 , 2 , 3.5 ), units = 'norm' )
1201
- with clear_and_catch_warnings () as warns :
1201
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1202
1202
warnings .simplefilter ('always' )
1203
1203
assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
1204
1204
(2 , 2 , 2 , 3.5 ))
@@ -1221,7 +1221,7 @@ def test_zooms_edge_cases(self):
1221
1221
units = 'badparam' )
1222
1222
1223
1223
def test_no_finite_values (self ):
1224
- with clear_and_catch_warnings () as warns :
1224
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1225
1225
warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
1226
1226
warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
1227
1227
warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
0 commit comments