Skip to content

Commit b08de65

Browse files
committed
add stacklevel=2 to warning
Signed-off-by: ytl0623 <[email protected]>
1 parent cbed38d commit b08de65

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

monai/losses/unified_focal_loss.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def forward(self, y_pred: torch.Tensor, y_true: torch.Tensor) -> torch.Tensor:
8080

8181
if self.to_onehot_y:
8282
if n_pred_ch == 1:
83-
warnings.warn("single channel prediction, `to_onehot_y=True` ignored.")
83+
warnings.warn("single channel prediction, `to_onehot_y=True` ignored.", stacklevel=2)
8484
else:
8585
if y_true.shape[1] != n_pred_ch:
8686
y_true = one_hot(y_true, num_classes=n_pred_ch)
@@ -185,7 +185,7 @@ def forward(self, y_pred: torch.Tensor, y_true: torch.Tensor) -> torch.Tensor:
185185

186186
if self.to_onehot_y:
187187
if n_pred_ch == 1:
188-
warnings.warn("single channel prediction, `to_onehot_y=True` ignored.")
188+
warnings.warn("single channel prediction, `to_onehot_y=True` ignored.", stacklevel=2)
189189
else:
190190
if y_true.shape[1] != n_pred_ch:
191191
y_true = one_hot(y_true, num_classes=n_pred_ch)

0 commit comments

Comments
 (0)