Skip to content

Commit a2819ca

Browse files
authored
Merge branch 'dev' into fix/issue-8775-compute-shape-offset-pytorch29
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
2 parents dfdb87d + cc92126 commit a2819ca

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

.github/workflows/pythonapp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
8383
- name: Install the dependencies
8484
run: |
85-
python -m pip install --user --upgrade pip wheel
85+
python -m pip install --user --upgrade pip wheel pybind11
8686
python -m pip install torch==2.5.1 torchvision==0.20.1
8787
cat "requirements-dev.txt"
8888
python -m pip install --no-build-isolation -r requirements-dev.txt

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ black==25.1.0
1818
isort>=5.1, <6, !=6.0.0
1919
ruff>=0.14.11,<0.15
2020
pytype>=2020.6.1, <=2024.4.11; platform_system != "Windows"
21+
pybind11
2122
types-setuptools
2223
mypy>=1.5.0, <1.12.0
2324
ninja

tests/data/utils/test_compute_shape_offset.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,26 @@
2121

2222
class TestComputeShapeOffset(unittest.TestCase):
2323
"""Unit tests for :func:`monai.data.utils.compute_shape_offset`."""
24+
25+
def test_pytorch_size_input(self):
26+
"""Validate `torch.Size` input produces expected shape and offset.
27+
28+
Returns:
29+
None.
30+
31+
Raises:
32+
AssertionError: If computed shape/offset are not as expected.
33+
"""
34+
# 1. Create a PyTorch Size object (which triggered the original bug)
35+
spatial_shape = torch.Size([10, 10, 10])
36+
in_affine = np.eye(4)
37+
out_affine = np.eye(4)
38+
39+
# 2. Feed it into the function
40+
shape, offset = compute_shape_offset(spatial_shape, in_affine, out_affine)
41+
42+
# 3. Prove it successfully processed the shape by checking its length
43+
self.assertEqual(len(shape), 3)
2444

2545
def setUp(self):
2646
"""Set up a 4x4 identity affine used across all test cases."""

0 commit comments

Comments
 (0)