Skip to content

Commit 61849bf

Browse files
aymuos15ericspod
andauthored
Fix docstring typos across codebase (#8688)
## Summary I was doing reviews with AI code reviewers and it caught some docstring typos. - Fix "nEfficient" to "an Efficient" in downsample.py, upsample.py, utils.py - Fix "utilty" to "utility" in utils.py - Fix "vaue" to "value" in utils.py - Fix "simmily" to "similarly" in unified_focal_loss.py (3 occurrences) - Fix "represenation" to "representation" in nacl_loss.py - Add missing f-string prefix in image_dissimilarity.py error message ## Test plan - [x] All modified files import successfully - [x] `unified_focal_loss.py` tests pass (4 passed) - [x] `nacl_loss.py` tests pass (7 passed) - [x] Upsample/Downsample block tests pass (177 passed) - [x] f-string fix verified - error message now correctly shows `num_bins` value **Note:** These are all non-breaking docstring/comment fixes only. Signed-off-by: Soumya Snigdha Kundu <soumya_snigdha.kundu@kcl.ac.uk> Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
1 parent 573fd9a commit 61849bf

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

monai/losses/image_dissimilarity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def __init__(
223223
"""
224224
super().__init__(reduction=LossReduction(reduction).value)
225225
if num_bins <= 0:
226-
raise ValueError("num_bins must > 0, got {num_bins}")
226+
raise ValueError(f"num_bins must > 0, got {num_bins}")
227227
bin_centers = torch.linspace(0.0, 1.0, num_bins) # (num_bins,)
228228
sigma = torch.mean(bin_centers[1:] - bin_centers[:-1]) * sigma_ratio
229229
self.kernel_type = look_up_option(kernel_type, ["gaussian", "b-spline"])

monai/losses/nacl_loss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def __init__(
8484

8585
def get_constr_target(self, mask: torch.Tensor) -> torch.Tensor:
8686
"""
87-
Converts the mask to one hot represenation and is smoothened with the selected spatial filter.
87+
Converts the mask to one hot representation and is smoothened with the selected spatial filter.
8888
8989
Args:
9090
mask: the shape should be BH[WD].

monai/losses/unified_focal_loss.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __init__(
4545
to_onehot_y: whether to convert `y` into the one-hot format. Defaults to False.
4646
delta : weight of the background. Defaults to 0.7.
4747
gamma : value of the exponent gamma in the definition of the Focal loss . Defaults to 0.75.
48-
epsilon : it defines a very small number each time. simmily smooth value. Defaults to 1e-7.
48+
epsilon : it defines a very small number each time. similarly smooth value. Defaults to 1e-7.
4949
"""
5050
super().__init__(reduction=LossReduction(reduction).value)
5151
self.to_onehot_y = to_onehot_y
@@ -109,7 +109,7 @@ def __init__(
109109
to_onehot_y : whether to convert `y` into the one-hot format. Defaults to False.
110110
delta : weight of the background. Defaults to 0.7.
111111
gamma : value of the exponent gamma in the definition of the Focal loss . Defaults to 0.75.
112-
epsilon : it defines a very small number each time. simmily smooth value. Defaults to 1e-7.
112+
epsilon : it defines a very small number each time. similarly smooth value. Defaults to 1e-7.
113113
"""
114114
super().__init__(reduction=LossReduction(reduction).value)
115115
self.to_onehot_y = to_onehot_y
@@ -169,7 +169,7 @@ def __init__(
169169
num_classes : number of classes, it only supports 2 now. Defaults to 2.
170170
delta : weight of the background. Defaults to 0.7.
171171
gamma : value of the exponent gamma in the definition of the Focal loss. Defaults to 0.75.
172-
epsilon : it defines a very small number each time. simmily smooth value. Defaults to 1e-7.
172+
epsilon : it defines a very small number each time. similarly smooth value. Defaults to 1e-7.
173173
weight : weight for each loss function, if it's none it's 0.5. Defaults to None.
174174
175175
Example:

monai/networks/blocks/downsample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class SubpixelDownsample(nn.Module):
232232
Example: (1, 1, 4, 4) with r=2 becomes (1, 4, 2, 2).
233233
234234
See: Shi et al., 2016, "Real-Time Single Image and Video Super-Resolution
235-
Using a nEfficient Sub-Pixel Convolutional Neural Network."
235+
Using an Efficient Sub-Pixel Convolutional Neural Network."
236236
237237
The pixel unshuffle mechanism is the inverse operation of:
238238
https://github.com/Project-MONAI/MONAI/blob/dev/monai/networks/blocks/upsample.py

monai/networks/blocks/upsample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class SubpixelUpsample(nn.Module):
195195
default single layer.
196196
197197
See: Shi et al., 2016, "Real-Time Single Image and Video Super-Resolution
198-
Using a nEfficient Sub-Pixel Convolutional Neural Network."
198+
Using an Efficient Sub-Pixel Convolutional Neural Network."
199199
200200
See: Aitken et al., 2017, "Checkerboard artifact free sub-pixel convolution".
201201

monai/networks/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ def pixelshuffle(x: torch.Tensor, spatial_dims: int, scale_factor: int) -> torch
372372
Apply pixel shuffle to the tensor `x` with spatial dimensions `spatial_dims` and scaling factor `scale_factor`.
373373
374374
See: Shi et al., 2016, "Real-Time Single Image and Video Super-Resolution
375-
Using a nEfficient Sub-Pixel Convolutional Neural Network."
375+
Using an Efficient Sub-Pixel Convolutional Neural Network."
376376
377377
See: Aitken et al., 2017, "Checkerboard artifact free sub-pixel convolution".
378378
@@ -1191,7 +1191,7 @@ def replace_modules_temp(
11911191

11921192
def freeze_layers(model: nn.Module, freeze_vars=None, exclude_vars=None):
11931193
"""
1194-
A utilty function to help freeze specific layers.
1194+
A utility function to help freeze specific layers.
11951195
11961196
Args:
11971197
model: a source PyTorch model to freeze layer.
@@ -1280,7 +1280,7 @@ def cast_all(x, from_dtype=torch.float16, to_dtype=torch.float32):
12801280
class CastToFloat(torch.nn.Module):
12811281
"""
12821282
Class used to add autocast protection for ONNX export
1283-
for forward methods with single return vaue
1283+
for forward methods with single return value
12841284
"""
12851285

12861286
def __init__(self, mod):

0 commit comments

Comments
 (0)