Skip to content

Commit 1e39a87

Browse files
committed
TEST: Clear nifti1 module warnings
1 parent 4c27592 commit 1e39a87

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
@@ -708,23 +708,23 @@ def test_recoded_fields(self):
708708
'alternating decreasing')
709709

710710
def test_general_init(self):
711-
with clear_and_catch_warnings() as warns:
711+
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
712712
warnings.filterwarnings('ignore', 'get_zooms', FutureWarning)
713713
warnings.filterwarnings('ignore', 'set_zooms', FutureWarning)
714714
warnings.filterwarnings('ignore', 'Unknown (spatial|time) units',
715715
UserWarning)
716716
super(TestNifti1PairHeader, self).test_general_init()
717717

718718
def test_from_header(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_from_header()
725725

726726
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:
728728
warnings.filterwarnings('ignore', 'get_zooms', FutureWarning)
729729
warnings.filterwarnings('ignore', 'set_zooms', FutureWarning)
730730
warnings.filterwarnings('ignore', 'Unknown (spatial|time) units',
@@ -1118,7 +1118,7 @@ def test_zooms_edge_cases(self):
11181118
img = img_klass(arr, aff)
11191119

11201120
# Unknown units = 2 warnings
1121-
with clear_and_catch_warnings() as warns:
1121+
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
11221122
warnings.simplefilter('always')
11231123
assert_array_almost_equal(img.header.get_zooms(units='norm'),
11241124
(1, 1, 1, 1))
@@ -1127,7 +1127,7 @@ def test_zooms_edge_cases(self):
11271127
units='norm', raise_unknown=True)
11281128

11291129
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:
11311131
warnings.simplefilter('always')
11321132
assert_array_almost_equal(img.header.get_zooms(units='norm'),
11331133
(1000, 1000, 1000, 1))
@@ -1143,7 +1143,7 @@ def test_zooms_edge_cases(self):
11431143
(0.001, 0.001, 0.001, 1))
11441144

11451145
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:
11471147
warnings.simplefilter('always')
11481148
assert_array_equal(img.header.get_zooms(units='norm'),
11491149
(1, 1, 1, 1))
@@ -1188,7 +1188,7 @@ def test_zooms_edge_cases(self):
11881188

11891189
# Non-temporal t units are not transformed
11901190
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:
11921192
warnings.simplefilter('always')
11931193
assert_array_almost_equal(img.header.get_zooms(units='norm'),
11941194
(1, 1, 1, 1.5))
@@ -1198,7 +1198,7 @@ def test_zooms_edge_cases(self):
11981198

11991199
# Non-temporal t units are not normalized
12001200
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:
12021202
warnings.simplefilter('always')
12031203
assert_array_almost_equal(img.header.get_zooms(units='norm'),
12041204
(2, 2, 2, 3.5))
@@ -1221,7 +1221,7 @@ def test_zooms_edge_cases(self):
12211221
units='badparam')
12221222

12231223
def test_no_finite_values(self):
1224-
with clear_and_catch_warnings() as warns:
1224+
with clear_and_catch_warnings(modules=(nifti1,)) as warns:
12251225
warnings.filterwarnings('ignore', 'get_zooms', FutureWarning)
12261226
warnings.filterwarnings('ignore', 'set_zooms', FutureWarning)
12271227
warnings.filterwarnings('ignore', 'Unknown (spatial|time) units',

0 commit comments

Comments
 (0)