Skip to content

test(nifti): cover 2D writer without target affine - #9173

Open
px12811 wants to merge 1 commit into
Project-MONAI:devfrom
px12811:9166-nibabel-writer-2d
Open

px12811 wants to merge 1 commit into
Project-MONAI:devfrom
px12811:9166-nibabel-writer-2d

Conversation

@px12811

@px12811 px12811 commented Oct 14, 2026

Copy link
Copy Markdown

Summary

Add a regression test for the public NibabelWriter path reported in #9166.

The reported TypeError is already resolved on dev by the general spatial_resample fix in #9080. This PR adds direct coverage for the original writer-level scenario so the regression cannot return without failing this test.

The new test writes a 2D channel-less array with spatial_ndim=None, original_affine=None, and no spatial_shape, then verifies the saved data and affine.

Validation

  • On e28a2c07^, the new test fails with the reported TypeError: '>=' not supported between instances of 'NoneType' and 'int'.
  • On current dev, the new test passes.
  • python -m pytest tests/data/test_nifti_rw.py -q: 42 passed
  • python -m pytest tests/transforms/test_spatial_resample.py -q: 76 passed
  • python -m pytest tests/data/test_image_rw.py -q: 2 passed, 28 skipped in the local minimal environment
  • ruff, black --check, isort --check-only, and git diff --check: passed

AI disclosure

This contribution was prepared with Codex assistance and reviewed by the submitter, who will respond to review comments personally.

Add a regression test for the NibabelWriter path reported in Project-MONAI#9166. The underlying fix landed in Project-MONAI#9080, but the writer-level behavior was not covered directly.

Assisted-by: Codex <noreply@openai.com>
Signed-off-by: peng xiang <78131130+px12811@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: Project-MONAI/MONAI/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e44bd8de-bfb1-47fb-9234-95cbaa588b0a
📥 Commits

Reviewing files that changed from the base of the PR and between cb35d45 and 87133d8.

📒 Files selected for processing: 1
  • tests/data/test_nifti_rw.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

Added a test that writes channel-less 2D data with spatial_ndim=None and no original_affine. The test checks that the saved voxel values remain unchanged and that the saved affine is the identity matrix.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 87133

This change adds focused regression coverage for writing channel-less 2D NIfTI data without a target affine; no merge-blocking risk is identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the added NIfTI regression test for the 2D writer path without a target affine.
Description check Passed The description clearly explains the regression scenario, test scope, expected behavior, and validation results. It does not use the repository template headings or include the issue reference and cha…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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