@@ -671,23 +671,23 @@ def test_recoded_fields(self):
671
671
'alternating decreasing' )
672
672
673
673
def test_general_init (self ):
674
- with clear_and_catch_warnings () as warns :
674
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
675
675
warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
676
676
warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
677
677
warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
678
678
UserWarning )
679
679
super (TestNifti1PairHeader , self ).test_general_init ()
680
680
681
681
def test_from_header (self ):
682
- with clear_and_catch_warnings () as warns :
682
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
683
683
warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
684
684
warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
685
685
warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
686
686
UserWarning )
687
687
super (TestNifti1PairHeader , self ).test_from_header ()
688
688
689
689
def test_data_shape_zooms_affine (self ):
690
- with clear_and_catch_warnings () as warns :
690
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
691
691
warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
692
692
warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
693
693
warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
@@ -1081,7 +1081,7 @@ def test_zooms_edge_cases(self):
1081
1081
img = img_klass (arr , aff )
1082
1082
1083
1083
# Unknown units = 2 warnings
1084
- with clear_and_catch_warnings () as warns :
1084
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1085
1085
warnings .simplefilter ('always' )
1086
1086
assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
1087
1087
(1 , 1 , 1 , 1 ))
@@ -1090,7 +1090,7 @@ def test_zooms_edge_cases(self):
1090
1090
units = 'norm' , raise_unknown = True )
1091
1091
1092
1092
img .header .set_xyzt_units (xyz = 'meter' )
1093
- with clear_and_catch_warnings () as warns :
1093
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1094
1094
warnings .simplefilter ('always' )
1095
1095
assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
1096
1096
(1000 , 1000 , 1000 , 1 ))
@@ -1106,7 +1106,7 @@ def test_zooms_edge_cases(self):
1106
1106
(0.001 , 0.001 , 0.001 , 1 ))
1107
1107
1108
1108
img .header .set_xyzt_units (t = 'sec' )
1109
- with clear_and_catch_warnings () as warns :
1109
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1110
1110
warnings .simplefilter ('always' )
1111
1111
assert_array_equal (img .header .get_zooms (units = 'norm' ),
1112
1112
(1 , 1 , 1 , 1 ))
@@ -1151,7 +1151,7 @@ def test_zooms_edge_cases(self):
1151
1151
1152
1152
# Non-temporal t units are not transformed
1153
1153
img .header .set_zooms ((1 , 1 , 1 , 1.5 ), units = ('mm' , 'ppm' ))
1154
- with clear_and_catch_warnings () as warns :
1154
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1155
1155
warnings .simplefilter ('always' )
1156
1156
assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
1157
1157
(1 , 1 , 1 , 1.5 ))
@@ -1161,7 +1161,7 @@ def test_zooms_edge_cases(self):
1161
1161
1162
1162
# Non-temporal t units are not normalized
1163
1163
img .header .set_zooms ((2 , 2 , 2 , 3.5 ), units = 'norm' )
1164
- with clear_and_catch_warnings () as warns :
1164
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1165
1165
warnings .simplefilter ('always' )
1166
1166
assert_array_almost_equal (img .header .get_zooms (units = 'norm' ),
1167
1167
(2 , 2 , 2 , 3.5 ))
@@ -1184,7 +1184,7 @@ def test_zooms_edge_cases(self):
1184
1184
units = 'badparam' )
1185
1185
1186
1186
def test_no_finite_values (self ):
1187
- with clear_and_catch_warnings () as warns :
1187
+ with clear_and_catch_warnings (modules = ( nifti1 ,) ) as warns :
1188
1188
warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
1189
1189
warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
1190
1190
warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
0 commit comments