Skip to content

Conversation

@johnzielke
Copy link
Contributor

I'm getting a warning at this line:
"Using a non-tuple sequence for multidimensional indexing is deprecated and will be changed in pytorch 2.9; use x instead of x. In pytorch 2.9 this will be interpreted as _tensor.py:1654
tensor index, x, which will result either in an error or a different result".

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

I'm getting a warning at this line:
"Using a non-tuple sequence for multidimensional indexing is deprecated and will be changed in pytorch 2.9; use x instead of x. In pytorch 2.9 this will be interpreted as     _tensor.py:1654
tensor index, x, which will result either in an error or a different result".

Signed-off-by: John Zielke <[email protected]>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 14, 2025

Walkthrough

Modified crop_or_pad_nd function in monai/transforms/croppad/functional.py to convert the crop indexing from img[to_crop] to img[tuple(to_crop)]. This ensures slices are passed as a proper tuple for multi-dimensional array indexing rather than as a list.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify tuple indexing behavior matches or improves upon list indexing in NumPy context
  • Confirm no edge cases exist where tuple vs. list indexing behaves differently for the cropping operation
  • Check if this change propagates correctly through any calling code

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly and specifically describes the main change: converting image cropping indexing to use tuples instead of lists.
Description check ✅ Passed Description includes the warning message and rationale, marks the change as non-breaking, but lacks explicit description of the fix applied.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 23c271e and 8a52c1c.

📒 Files selected for processing (1)
  • monai/transforms/croppad/functional.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

Review the Python code for quality and correctness. Ensure variable names adhere to PEP8 style guides, are sensible and informative in regards to their function, though permitting simple names for loop and comprehension variables. Ensure routine names are meaningful in regards to their function and use verbs, adjectives, and nouns in a semantically appropriate way. Docstrings should be present for all definition which describe each variable, return value, and raised exception in the appropriate section of the Google-style of docstrings. Examine code for logical error or inconsistencies, and suggest what may be changed to addressed these. Suggest any enhancements for code improving efficiency, maintainability, comprehensibility, and correctness. Ensure new or modified definitions will be covered by existing or new unit tests.

Files:

  • monai/transforms/croppad/functional.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: flake8-py3 (pytype)
  • GitHub Check: quick-py3 (macOS-latest)
🔇 Additional comments (1)
monai/transforms/croppad/functional.py (1)

147-147: Fix is correct; verify test coverage for the code path.

The list-to-tuple conversion is the proper approach for PyTorch 2.9+ compatibility and addresses the deprecation warning. However, search results show no direct unit tests for crop_or_pad_nd and the resample function in lazy/utils.py (which calls crop_or_pad_nd at line 221) doesn't appear to be tested in the integration suite.

Verify that existing tests exercise the cropping code path, either directly or through spatial resampling workflows. If not, add test coverage for this functionality.


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 and usage tips.

@johnzielke johnzielke marked this pull request as ready for review November 14, 2025 22:30
Copy link
Member

@ericspod ericspod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting this, @johnzielke I think we can merge this one soon, @KumoLiu please trigger blossom when possible.

@KumoLiu
Copy link
Contributor

KumoLiu commented Nov 18, 2025

/build

@KumoLiu KumoLiu enabled auto-merge (squash) November 18, 2025 04:53
@KumoLiu KumoLiu merged commit 806c0e8 into Project-MONAI:dev Nov 18, 2025
27 checks passed
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.

3 participants