Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion monai/inferers/inferer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1773,7 +1773,7 @@ def __init__(
super().__init__(scheduler=scheduler)
self.scale_factor = scale_factor
if (ldm_latent_shape is None) ^ (autoencoder_latent_shape is None):
raise ValueError("If ldm_latent_shape is None, autoencoder_latent_shape must be None" "and vice versa.")
raise ValueError("If ldm_latent_shape is None, autoencoder_latent_shape must be None and vice versa.")
self.ldm_latent_shape = ldm_latent_shape
self.autoencoder_latent_shape = autoencoder_latent_shape
if self.ldm_latent_shape is not None and self.autoencoder_latent_shape is not None:
Expand Down
4 changes: 2 additions & 2 deletions monai/metrics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def do_metric_reduction(

Raises:
ValueError: When ``reduction`` is not one of
["mean", "sum", "mean_batch", "sum_batch", "mean_channel", "sum_channel" "none"].
["mean", "sum", "mean_batch", "sum_batch", "mean_channel", "sum_channel", "none"].
"""

# some elements might be Nan (if ground truth y was missing (zeros))
Expand Down Expand Up @@ -141,7 +141,7 @@ def do_metric_reduction(
elif reduction != MetricReduction.NONE:
raise ValueError(
f"Unsupported reduction: {reduction}, available options are "
'["mean", "sum", "mean_batch", "sum_batch", "mean_channel", "sum_channel" "none"].'
'["mean", "sum", "mean_batch", "sum_batch", "mean_channel", "sum_channel", "none"].'
)
return f, not_nans

Expand Down
2 changes: 1 addition & 1 deletion monai/networks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def pixelunshuffle(x: torch.Tensor, spatial_dims: int, scale_factor: int) -> tor

if any(d % factor != 0 for d in input_size[2:]):
raise ValueError(
f"All spatial dimensions must be divisible by factor {factor}. " f", spatial shape is: {input_size[2:]}"
f"All spatial dimensions must be divisible by factor {factor}, spatial shape is: {input_size[2:]}"
)
output_size = [batch_size, new_channels] + [d // factor for d in input_size[2:]]
reshaped_size = [batch_size, channels] + sum([[d // factor, factor] for d in input_size[2:]], [])
Expand Down
5 changes: 5 additions & 0 deletions tests/networks/utils/test_pixelunshuffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ def test_different_scale_factor(self):
out = pixelunshuffle(x, spatial_dims=2, scale_factor=3)
torch.testing.assert_close(out, torch.pixel_unshuffle(x, 3))

def test_indivisible_spatial_dims(self):
x = torch.randn(1, 2, 7, 8)
with self.assertRaisesRegex(ValueError, r"divisible by factor 2, spatial shape is: \[7, 8\]"):
pixelunshuffle(x, spatial_dims=2, scale_factor=2)
Comment thread
coderabbitai[bot] marked this conversation as resolved.

def test_inverse_operation(self):
x = torch.arange(4096).reshape(1, 8, 8, 8, 8)
shuffled = pixelshuffle(x, spatial_dims=3, scale_factor=2)
Expand Down
Loading