Skip to content

Commit 6359e43

Browse files
committed
Fix Incompatible types in assignment
monai/transforms/intensity/dictionary.py:334: error: Incompatible types in assignment (expression has type "Union[Tuple[Any, ...], List[Any]]", variable has type "Tuple[float, Any]")
1 parent 370fb6e commit 6359e43

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

monai/transforms/intensity/dictionary.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
Class names are ended with 'd' to denote dictionary-based transforms.
1616
"""
1717

18-
from typing import Union, Optional
18+
from typing import Union, Optional, Tuple
1919

2020
import numpy as np
2121

@@ -324,13 +324,15 @@ class RandAdjustContrastd(Randomizable, MapTransform):
324324
If single number, value is picked from (0.5, gamma), default is (0.5, 4.5).
325325
"""
326326

327-
def __init__(self, keys: KeysCollection, prob=0.1, gamma=(0.5, 4.5)):
327+
def __init__(self, keys: KeysCollection, prob=0.1, gamma: Union[Tuple[float, float], float] = (0.5, 4.5)):
328328
super().__init__(keys)
329329
self.prob = prob
330+
self.gamma: Tuple[float, float]
330331
if not isinstance(gamma, (tuple, list)):
331332
assert gamma > 0.5, "if gamma is single number, must greater than 0.5 and value is picked from (0.5, gamma)"
332333
self.gamma = (0.5, gamma)
333334
else:
335+
assert len(gamma) == 2, "gamma should be a number or pair of numbers."
334336
self.gamma = gamma
335337
assert len(self.gamma) == 2, "gamma should be a number or pair of numbers."
336338

0 commit comments

Comments
 (0)