Skip to content

Commit f2d063b

Browse files
committed
TEST: Expire some deprecation tests
1 parent 9ed6c45 commit f2d063b

File tree

7 files changed

+15
-12
lines changed

7 files changed

+15
-12
lines changed

nibabel/tests/test_analyze.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ def test_default_header(self):
716716

717717
def test_data_hdr_cache(self):
718718
# test the API for loaded images, such that the data returned
719-
# from np.asanyarray(img.dataobj) and img,get_fdata() are not
719+
# from np.asanyarray(img.dataobj) and img.get_fdata() are not
720720
# affected by subsequent changes to the header.
721721
IC = self.image_class
722722
# save an image to a file map
@@ -740,14 +740,6 @@ def test_data_hdr_cache(self):
740740
assert hdr.get_data_dtype() == np.dtype(np.uint8)
741741
assert_array_equal(img2.get_fdata(), data)
742742
assert_array_equal(np.asanyarray(img2.dataobj), data)
743-
# now check read_img_data function - here we do see the changed
744-
# header
745-
with pytest.deprecated_call(match="from version: 3.2"):
746-
sc_data = read_img_data(img2)
747-
assert sc_data.shape == (3, 2, 2)
748-
with pytest.deprecated_call(match="from version: 3.2"):
749-
us_data = read_img_data(img2, prefer='unscaled')
750-
assert us_data.shape == (3, 2, 2)
751743

752744
def test_affine_44(self):
753745
IC = self.image_class

nibabel/tests/test_image_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
from numpy.testing import assert_almost_equal, assert_array_equal, assert_warns, assert_allclose
5050
from nibabel.testing import (bytesio_round_trip, bytesio_filemap, assert_data_similar,
51-
clear_and_catch_warnings, nullcontext)
51+
clear_and_catch_warnings, nullcontext, expires)
5252
from ..tmpdirs import InTemporaryDirectory
5353

5454
from .test_api_validators import ValidateAPI
@@ -170,8 +170,8 @@ def validate_no_slicing(self, imaker, params):
170170
with pytest.raises(TypeError):
171171
img[:]
172172

173+
@expires("5.0.0")
173174
def validate_get_data_deprecated(self, imaker, params):
174-
# Check deprecated header API
175175
img = imaker()
176176
with pytest.deprecated_call():
177177
data = img.get_data()

nibabel/tests/test_image_load_save.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from ..volumeutils import native_code, swapped_code
3030
from ..optpkg import optional_package
3131
from ..spatialimages import SpatialImage
32+
from ..testing import expires
3233

3334
from numpy.testing import assert_array_equal, assert_array_almost_equal
3435
import pytest
@@ -270,6 +271,7 @@ def test_filename_save():
270271
shutil.rmtree(pth)
271272

272273

274+
@expires('5.0.0')
273275
def test_guessed_image_type():
274276
# Test whether we can guess the image type from example files
275277
with pytest.deprecated_call():

nibabel/tests/test_loadsave.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from ..filebasedimages import ImageFileError
1515
from ..tmpdirs import InTemporaryDirectory, TemporaryDirectory
1616
from ..openers import Opener
17+
from ..testing import expires
1718

1819
from ..optpkg import optional_package
1920
_, have_scipy, _ = optional_package('scipy')
@@ -27,6 +28,7 @@
2728
data_path = pjoin(dirname(__file__), 'data')
2829

2930

31+
@expires("5.0.0")
3032
def test_read_img_data():
3133
fnames_test = [
3234
'example4d.nii.gz',
@@ -120,6 +122,7 @@ def test_signature_matches_extension(tmp_path):
120122
assert msg == ""
121123

122124

125+
@expires("5.0.0")
123126
def test_read_img_data_nifti():
124127
shape = (2, 3, 4)
125128
data = np.random.normal(size=shape)

nibabel/tests/test_onetime.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import pytest
22
from nibabel.onetime import auto_attr, setattr_on_read
3+
from nibabel.testing import expires
34

45

6+
@expires('5.0.0')
57
def test_setattr_on_read():
68
with pytest.deprecated_call():
79
class MagicProp:

nibabel/tests/test_orientations.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
ornt2axcodes, axcodes2ornt, aff2axcodes)
2121

2222
from ..affines import from_matvec, to_matvec
23+
from ..testing import expires
2324

2425

2526
IN_ARRS = [np.eye(4),
@@ -353,6 +354,7 @@ def test_inv_ornt_aff():
353354
inv_ornt_aff([[0, 1], [1, -1], [np.nan, np.nan]], (3, 4, 5))
354355

355356

357+
@expires('5.0.0')
356358
def test_flip_axis_deprecation():
357359
a = np.arange(24).reshape((2, 3, 4))
358360
axis = 1

nibabel/tests/test_spatialimages.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
bytesio_round_trip,
2727
clear_and_catch_warnings,
2828
suppress_warnings,
29-
memmap_after_ufunc
29+
memmap_after_ufunc,
30+
expires,
3031
)
3132

3233
from ..tmpdirs import InTemporaryDirectory
@@ -358,6 +359,7 @@ def test_get_fdata(self):
358359
assert rt_img.get_fdata() is not out_data
359360
assert (rt_img.get_fdata() == in_data).all()
360361

362+
@expires("5.0.0")
361363
def test_get_data(self):
362364
# Test array image and proxy image interface
363365
img_klass = self.image_class

0 commit comments

Comments
 (0)