Skip to content

Commit 210b1f2

Browse files
committed
TEST: Clear nifti1 module warnings
1 parent b606a2d commit 210b1f2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

nibabel/tests/test_nifti1.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -671,23 +671,23 @@ def test_recoded_fields(self):
671671
'alternating decreasing')
672672

673673
def test_general_init(self):
674-
with clear_and_catch_warnings() as warns:
674+
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
675675
warnings.filterwarnings('ignore', 'get_zooms', FutureWarning)
676676
warnings.filterwarnings('ignore', 'set_zooms', FutureWarning)
677677
warnings.filterwarnings('ignore', 'Unknown (spatial|time) units',
678678
UserWarning)
679679
super(TestNifti1PairHeader, self).test_general_init()
680680

681681
def test_from_header(self):
682-
with clear_and_catch_warnings() as warns:
682+
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
683683
warnings.filterwarnings('ignore', 'get_zooms', FutureWarning)
684684
warnings.filterwarnings('ignore', 'set_zooms', FutureWarning)
685685
warnings.filterwarnings('ignore', 'Unknown (spatial|time) units',
686686
UserWarning)
687687
super(TestNifti1PairHeader, self).test_from_header()
688688

689689
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:
691691
warnings.filterwarnings('ignore', 'get_zooms', FutureWarning)
692692
warnings.filterwarnings('ignore', 'set_zooms', FutureWarning)
693693
warnings.filterwarnings('ignore', 'Unknown (spatial|time) units',
@@ -1081,7 +1081,7 @@ def test_zooms_edge_cases(self):
10811081
img = img_klass(arr, aff)
10821082

10831083
# Unknown units = 2 warnings
1084-
with clear_and_catch_warnings() as warns:
1084+
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
10851085
warnings.simplefilter('always')
10861086
assert_array_almost_equal(img.header.get_zooms(units='norm'),
10871087
(1, 1, 1, 1))
@@ -1090,7 +1090,7 @@ def test_zooms_edge_cases(self):
10901090
units='norm', raise_unknown=True)
10911091

10921092
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:
10941094
warnings.simplefilter('always')
10951095
assert_array_almost_equal(img.header.get_zooms(units='norm'),
10961096
(1000, 1000, 1000, 1))
@@ -1106,7 +1106,7 @@ def test_zooms_edge_cases(self):
11061106
(0.001, 0.001, 0.001, 1))
11071107

11081108
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:
11101110
warnings.simplefilter('always')
11111111
assert_array_equal(img.header.get_zooms(units='norm'),
11121112
(1, 1, 1, 1))
@@ -1151,7 +1151,7 @@ def test_zooms_edge_cases(self):
11511151

11521152
# Non-temporal t units are not transformed
11531153
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:
11551155
warnings.simplefilter('always')
11561156
assert_array_almost_equal(img.header.get_zooms(units='norm'),
11571157
(1, 1, 1, 1.5))
@@ -1161,7 +1161,7 @@ def test_zooms_edge_cases(self):
11611161

11621162
# Non-temporal t units are not normalized
11631163
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:
11651165
warnings.simplefilter('always')
11661166
assert_array_almost_equal(img.header.get_zooms(units='norm'),
11671167
(2, 2, 2, 3.5))
@@ -1184,7 +1184,7 @@ def test_zooms_edge_cases(self):
11841184
units='badparam')
11851185

11861186
def test_no_finite_values(self):
1187-
with clear_and_catch_warnings() as warns:
1187+
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
11881188
warnings.filterwarnings('ignore', 'get_zooms', FutureWarning)
11891189
warnings.filterwarnings('ignore', 'set_zooms', FutureWarning)
11901190
warnings.filterwarnings('ignore', 'Unknown (spatial|time) units',

0 commit comments

Comments
 (0)