Skip to content

Commit ac4283f

Browse files
committed
TEST: Clear nifti1 module warnings
1 parent 882ada3 commit ac4283f

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
@@ -716,23 +716,23 @@ def test_recoded_fields(self):
716716
assert hdr.get_value_label('slice_code') == 'alternating decreasing'
717717

718718
def test_general_init(self):
719-
with clear_and_catch_warnings() as warns:
719+
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
720720
warnings.filterwarnings('ignore', 'get_zooms', FutureWarning)
721721
warnings.filterwarnings('ignore', 'set_zooms', FutureWarning)
722722
warnings.filterwarnings('ignore', 'Unknown (spatial|time) units',
723723
UserWarning)
724724
super(TestNifti1PairHeader, self).test_general_init()
725725

726726
def test_from_header(self):
727-
with clear_and_catch_warnings() as warns:
727+
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
728728
warnings.filterwarnings('ignore', 'get_zooms', FutureWarning)
729729
warnings.filterwarnings('ignore', 'set_zooms', FutureWarning)
730730
warnings.filterwarnings('ignore', 'Unknown (spatial|time) units',
731731
UserWarning)
732732
super(TestNifti1PairHeader, self).test_from_header()
733733

734734
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:
736736
warnings.filterwarnings('ignore', 'get_zooms', FutureWarning)
737737
warnings.filterwarnings('ignore', 'set_zooms', FutureWarning)
738738
warnings.filterwarnings('ignore', 'Unknown (spatial|time) units',
@@ -1130,7 +1130,7 @@ def test_zooms_edge_cases(self):
11301130
img = img_klass(arr, aff)
11311131

11321132
# Unknown units = 2 warnings
1133-
with clear_and_catch_warnings() as warns:
1133+
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
11341134
warnings.simplefilter('always')
11351135
assert_array_almost_equal(img.header.get_zooms(units='norm'),
11361136
(1, 1, 1, 1))
@@ -1139,7 +1139,7 @@ def test_zooms_edge_cases(self):
11391139
units='norm', raise_unknown=True)
11401140

11411141
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:
11431143
warnings.simplefilter('always')
11441144
assert_array_almost_equal(img.header.get_zooms(units='norm'),
11451145
(1000, 1000, 1000, 1))
@@ -1155,7 +1155,7 @@ def test_zooms_edge_cases(self):
11551155
(0.001, 0.001, 0.001, 1))
11561156

11571157
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:
11591159
warnings.simplefilter('always')
11601160
assert_array_equal(img.header.get_zooms(units='norm'),
11611161
(1, 1, 1, 1))
@@ -1200,7 +1200,7 @@ def test_zooms_edge_cases(self):
12001200

12011201
# Non-temporal t units are not transformed
12021202
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:
12041204
warnings.simplefilter('always')
12051205
assert_array_almost_equal(img.header.get_zooms(units='norm'),
12061206
(1, 1, 1, 1.5))
@@ -1210,7 +1210,7 @@ def test_zooms_edge_cases(self):
12101210

12111211
# Non-temporal t units are not normalized
12121212
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:
12141214
warnings.simplefilter('always')
12151215
assert_array_almost_equal(img.header.get_zooms(units='norm'),
12161216
(2, 2, 2, 3.5))
@@ -1233,7 +1233,7 @@ def test_zooms_edge_cases(self):
12331233
units='badparam')
12341234

12351235
def test_no_finite_values(self):
1236-
with clear_and_catch_warnings() as warns:
1236+
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
12371237
warnings.filterwarnings('ignore', 'get_zooms', FutureWarning)
12381238
warnings.filterwarnings('ignore', 'set_zooms', FutureWarning)
12391239
warnings.filterwarnings('ignore', 'Unknown (spatial|time) units',

0 commit comments

Comments
 (0)