Skip to content

TEST: Cover the doctest, the ROI assertion and slice_affine directly - #1

Open
Arthur031221 wants to merge 1 commit into
wterrr:fix/1533-slicer-negative-startsfrom
Arthur031221:contrib/1533-doctest-and-roi
Open

TEST: Cover the doctest, the ROI assertion and slice_affine directly#1
Arthur031221 wants to merge 1 commit into
wterrr:fix/1533-slicer-negative-startsfrom
Arthur031221:contrib/1533-doctest-and-roi

Conversation

@Arthur031221

Copy link
Copy Markdown

The three pieces from nipy#1533 that aren't in this branch yet. Thanks for the offer.

doc/source/nibabel_images.rst prints an X translation of 117.86 for the flipped image, which is the pre-fix value. With your change in place that doctest fails:

Document: nibabel_images
70 passed and 1 failed.

With this it's 71 passed, 0 failed. Worth catching now because the doctest job is continue-on-error: true, so it would land without anything going red.

test_nib_roi asserted np.allclose(in_sliced.affine, out_img.affine). That compares the slicer against itself, so it passes whatever the slicer does. It already exercises -j -1:1:-1, which is why this bug was never caught there. Comparing against an independently calculated affine instead: with your fix reverted the old assertion still gives 12 passed, the new one gives 2 failed.

One line in test_slicer_preserves_ras_position asserts slice_affine directly rather than only through img.slicer, since effigies asked for the affine calculator and the slicer separately. Reverting the fix takes it from 10 passed to 10 failed.

I put it inside your existing loop rather than adding a parallel test, so the same nine slicers cover both. Say the word if you would rather have it separate, or want any of this dropped.

Three things the fix needs alongside it.

The flip example in doc/source/nibabel_images.rst prints an X translation of
117.86, which is the value from before the fix. With the fix in place that
doctest fails, and the job that would catch it is continue-on-error, so it
would land quietly.

test_nib_roi asserted np.allclose(in_sliced.affine, out_img.affine), which
compares the slicer against itself and passes whatever the slicer does. It
already exercises -j -1:1:-1, so that assertion is why this was never caught
there. It now compares both against an affine calculated independently.

test_slicer_preserves_ras_position went through img.slicer only. One line
asserts slice_affine directly as well, so the affine calculator is covered on
its own rather than through its caller.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant