Skip to content

Commit 4941405

Browse files
committed
Fix three malformed error messages
Adjacent string literals concatenate in Python, and in two places the join produces text the author clearly did not intend: monai/networks/utils.py:443 pixelunshuffle() "...divisible by factor 2. , spatial shape is: [7, 8]" The second literal opens with ", " while the first already closed with ". ", so the rendered message carries a stray ". ,". monai/inferers/inferer.py:1776 LatentDiffusionInferer.__init__() "...autoencoder_latent_shape must be Noneand vice versa." No trailing space on the first literal, so two words run together. The third is a plain typo in the same family, a missing comma in a list of valid options, appearing in both the raised message and the docstring that documents it: monai/metrics/utils.py:104,144 do_metric_reduction() '[..., "mean_channel", "sum_channel" "none"].' Every sibling message in monai/losses/ writes this list fully comma-separated. All three are user-visible text only; no behaviour changes. Signed-off-by: Hans Johnson <hans-johnson@uiowa.edu>
1 parent c1240a2 commit 4941405

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

monai/inferers/inferer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,7 @@ def __init__(
17731773
super().__init__(scheduler=scheduler)
17741774
self.scale_factor = scale_factor
17751775
if (ldm_latent_shape is None) ^ (autoencoder_latent_shape is None):
1776-
raise ValueError("If ldm_latent_shape is None, autoencoder_latent_shape must be None" "and vice versa.")
1776+
raise ValueError("If ldm_latent_shape is None, autoencoder_latent_shape must be None and vice versa.")
17771777
self.ldm_latent_shape = ldm_latent_shape
17781778
self.autoencoder_latent_shape = autoencoder_latent_shape
17791779
if self.ldm_latent_shape is not None and self.autoencoder_latent_shape is not None:

monai/metrics/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def do_metric_reduction(
101101
102102
Raises:
103103
ValueError: When ``reduction`` is not one of
104-
["mean", "sum", "mean_batch", "sum_batch", "mean_channel", "sum_channel" "none"].
104+
["mean", "sum", "mean_batch", "sum_batch", "mean_channel", "sum_channel", "none"].
105105
"""
106106

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

monai/networks/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def pixelunshuffle(x: torch.Tensor, spatial_dims: int, scale_factor: int) -> tor
440440

441441
if any(d % factor != 0 for d in input_size[2:]):
442442
raise ValueError(
443-
f"All spatial dimensions must be divisible by factor {factor}. " f", spatial shape is: {input_size[2:]}"
443+
f"All spatial dimensions must be divisible by factor {factor}, spatial shape is: {input_size[2:]}"
444444
)
445445
output_size = [batch_size, new_channels] + [d // factor for d in input_size[2:]]
446446
reshaped_size = [batch_size, channels] + sum([[d // factor, factor] for d in input_size[2:]], [])

0 commit comments

Comments
 (0)