Skip to content

Commit 1b05c0f

Browse files
committed
TEST: Move slicing test from test_get_data to test_slicer
1 parent f2d063b commit 1b05c0f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

nibabel/tests/test_spatialimages.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,6 @@ def test_get_data(self):
366366
in_data_template = np.arange(24, dtype=np.int16).reshape((2, 3, 4))
367367
in_data = in_data_template.copy()
368368
img = img_klass(in_data, None)
369-
# Can't slice into the image object:
370-
with pytest.raises(TypeError) as exception_manager:
371-
img[0, 0, 0]
372-
# Make sure the right message gets raised:
373-
assert (str(exception_manager.value) ==
374-
"Cannot slice image objects; consider using "
375-
"`img.slicer[slice]` to generate a sliced image (see "
376-
"documentation for caveats) or slicing image array data "
377-
"with `img.dataobj[slice]` or `img.get_fdata()[slice]`")
378369
assert in_data is img.dataobj
379370
with pytest.deprecated_call():
380371
out_data = img.get_data()
@@ -413,6 +404,16 @@ def test_slicer(self):
413404
in_data = in_data_template.copy().reshape(dshape)
414405
img = img_klass(in_data, base_affine.copy())
415406

407+
# Can't slice into the image object:
408+
with pytest.raises(TypeError) as exception_manager:
409+
img[0, 0, 0]
410+
# Make sure the right message gets raised:
411+
assert (str(exception_manager.value) ==
412+
"Cannot slice image objects; consider using "
413+
"`img.slicer[slice]` to generate a sliced image (see "
414+
"documentation for caveats) or slicing image array data "
415+
"with `img.dataobj[slice]` or `img.get_fdata()[slice]`")
416+
416417
if not spatial_axes_first(img):
417418
with pytest.raises(ValueError):
418419
img.slicer

0 commit comments

Comments
 (0)