Skip to content

Commit 225766b

Browse files
committed
address coderabbit comments
1 parent caf39ef commit 225766b

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

monai/losses/cldice.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ def __init__(
161161
raise TypeError(f"other_act must be None or callable but is {type(other_act).__name__}.")
162162
if int(sigmoid) + int(softmax) + int(other_act is not None) > 1:
163163
raise ValueError("Incompatible values: more than 1 of [sigmoid=True, softmax=True, other_act is not None].")
164+
if not isinstance(iter_, int):
165+
raise TypeError(f"iter_ must be an integer but got {type(iter_).__name__}.")
164166
if iter_ < 0:
165167
raise ValueError(f"iter_ must be a non-negative integer but got {iter_}.")
166168
self.iter = iter_
@@ -299,6 +301,8 @@ def __init__(
299301
300302
"""
301303
super().__init__()
304+
if not 0.0 <= alpha <= 1.0:
305+
raise ValueError(f"alpha must be in [0, 1] but got {alpha}.")
302306
self.dice = DiceLoss(
303307
include_background=include_background,
304308
to_onehot_y=False,

tests/losses/test_cldice_loss.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272

7373

7474
class TestSoftclDiceLoss(unittest.TestCase):
75-
7675
@parameterized.expand(CLDICE_CASES)
7776
def test_result(self, loss_params, input_data, expected_val):
7877
loss = SoftclDiceLoss(**loss_params)
@@ -109,7 +108,6 @@ def test_invalid_other_act(self):
109108

110109

111110
class TestSoftDiceclDiceLoss(unittest.TestCase):
112-
113111
@parameterized.expand(COMBINED_CASES)
114112
def test_result(self, loss_params, input_data, expected_val):
115113
loss = SoftDiceclDiceLoss(**loss_params)

0 commit comments

Comments
 (0)