Skip to content

Commit 806c0e8

Browse files
authored
Fix index using tuple for image cropping operation (#8633)
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 <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] 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. Signed-off-by: John Zielke <j.l.zielke@gmail.com>
1 parent 23c271e commit 806c0e8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

monai/transforms/croppad/functional.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def crop_or_pad_nd(img: torch.Tensor, translation_mat, spatial_size: tuple[int,
144144
_mode = _convert_pt_pad_mode(mode)
145145
img = pad_nd(img, to_pad, mode=_mode, **kwargs)
146146
if do_crop:
147-
img = img[to_crop]
147+
img = img[tuple(to_crop)]
148148
return img
149149

150150

0 commit comments

Comments
 (0)