@@ -83,19 +83,6 @@ class TestNifti1PairHeader(tana.TestAnalyzeHeader, tspm.HeaderScalingMixin):
8383 np .longcomplex ))
8484 tana .add_intp (supported_np_types )
8585
86- def setUp (self ):
87- # Add warning filters for duration of test case
88- self ._wctx = warnings .catch_warnings ()
89- self ._wctx .__enter__ ()
90- warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
91- warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
92- warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
93- UserWarning )
94-
95- def tearDown (self ):
96- # Restore warning filters
97- self ._wctx .__exit__ ()
98-
9986 def test_empty (self ):
10087 tana .TestAnalyzeHeader .test_empty (self )
10188 hdr = self .header_class ()
@@ -731,6 +718,30 @@ def test_recoded_fields(self):
731718 hdr ['slice_code' ] = 4 # alternating decreasing
732719 assert hdr .get_value_label ('slice_code' ) == 'alternating decreasing'
733720
721+ def test_general_init (self ):
722+ with clear_and_catch_warnings () as warns :
723+ warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
724+ warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
725+ warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
726+ UserWarning )
727+ super (TestNifti1PairHeader , self ).test_general_init ()
728+
729+ def test_from_header (self ):
730+ with clear_and_catch_warnings () as warns :
731+ warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
732+ warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
733+ warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
734+ UserWarning )
735+ super (TestNifti1PairHeader , self ).test_from_header ()
736+
737+ def test_data_shape_zooms_affine (self ):
738+ with clear_and_catch_warnings () as warns :
739+ warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
740+ warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
741+ warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
742+ UserWarning )
743+ super (TestNifti1PairHeader , self ).test_data_shape_zooms_affine ()
744+
734745
735746def unshear_44 (affine ):
736747 RZS = affine [:3 , :3 ]
@@ -778,19 +789,6 @@ class TestNifti1Pair(tana.TestAnalyzeImage, tspm.ImageScalingMixin):
778789 image_class = Nifti1Pair
779790 supported_np_types = TestNifti1PairHeader .supported_np_types
780791
781- def setUp (self ):
782- # Add warning filters for duration of test case
783- self ._wctx = warnings .catch_warnings ()
784- self ._wctx .__enter__ ()
785- warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
786- warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
787- warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
788- UserWarning )
789-
790- def tearDown (self ):
791- # Restore warning filters
792- self ._wctx .__exit__ ()
793-
794792 def test_int64_warning (self ):
795793 # Verify that initializing with (u)int64 data and no
796794 # header/dtype info produces a warning
@@ -1311,6 +1309,14 @@ def test_zooms_edge_cases(self):
13111309 assert_raises (ValueError , img .header .set_zooms , (3 , 3 , 3 , 3.5 ),
13121310 units = 'badparam' )
13131311
1312+ def test_no_finite_values (self ):
1313+ with clear_and_catch_warnings () as warns :
1314+ warnings .filterwarnings ('ignore' , 'get_zooms' , FutureWarning )
1315+ warnings .filterwarnings ('ignore' , 'set_zooms' , FutureWarning )
1316+ warnings .filterwarnings ('ignore' , 'Unknown (spatial|time) units' ,
1317+ UserWarning )
1318+ super (TestNifti1Pair , self ).test_no_finite_values ()
1319+
13141320
13151321class TestNifti1Image (TestNifti1Pair ):
13161322 # Run analyze-flavor spatialimage tests
0 commit comments