Conversation
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
📝 WalkthroughWalkthroughSix test methods in the multiscalessim metric test file were renamed to follow proper pytest naming conventions. Method names were updated to consistently use snake_case with the Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/metrics/test_compute_multiscalessim_metric.py (1)
75-79:⚠️ Potential issue | 🟡 Minor
test_small_inputsis testing the wrong condition.The input
torch.randn(1, 1, 16, 16, 16)is a 5-D tensor (3 spatial dims) passed to aspatial_dims=2metric. This raisesValueErrordue to a dimension mismatch — identical in kind to whattest_input_ill_input_shape3dalready covers. The intended scenario (a spatially-too-small 2-D input exhausted by MS-SSIM's downsampling cascade) is not exercised at all.🛠️ Proposed fix
- def test_small_inputs(self): - metric = MultiScaleSSIMMetric(spatial_dims=2) - - with self.assertRaises(ValueError): - metric(torch.randn(1, 1, 16, 16, 16), torch.randn(1, 1, 16, 16, 16)) + def test_small_inputs(self): + metric = MultiScaleSSIMMetric(spatial_dims=2) + + with self.assertRaises(ValueError): + metric(torch.randn(1, 1, 4, 4), torch.randn(1, 1, 4, 4))🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/metrics/test_compute_multiscalessim_metric.py` around lines 75 - 79, The test_small_inputs currently passes 5-D tensors to MultiScaleSSIMMetric(spatial_dims=2) causing a dimension-mismatch error (already covered by test_input_ill_input_shape3d); change test_small_inputs to pass 4-D tensors with valid rank but too-small spatial dimensions (e.g., torch.randn(1,1,8,8) or smaller) so the MS-SSIM downsampling cascade triggers a ValueError; update the assertion to use those 4-D small spatial inputs and keep the expect-ValueError assertion on MultiScaleSSIMMetric to avoid duplicating the shape-mismatch case.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@tests/metrics/test_compute_multiscalessim_metric.py`:
- Around line 75-79: The test_small_inputs currently passes 5-D tensors to
MultiScaleSSIMMetric(spatial_dims=2) causing a dimension-mismatch error (already
covered by test_input_ill_input_shape3d); change test_small_inputs to pass 4-D
tensors with valid rank but too-small spatial dimensions (e.g.,
torch.randn(1,1,8,8) or smaller) so the MS-SSIM downsampling cascade triggers a
ValueError; update the assertion to use those 4-D small spatial inputs and keep
the expect-ValueError assertion on MultiScaleSSIMMetric to avoid duplicating the
shape-mismatch case.
|
Hi @ericspod! Thanks for the fix, LGTM! I suggest that maybe changing this in |
|
Unforetunately, it is not possible to add a code suggestion to other things than those edited in the PR (or at least I do think so), so I'll just add another PR in order to fix these issues so that you don't have to worry about this. 👍 And thanks again for the fix! |
benediktjohannes
left a comment
There was a problem hiding this comment.
Nice changes! Thanks!
Description
This fixes erroneous test names flagged elsewhere by coderabbit.
Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests --disttests.make htmlcommand in thedocs/folder.