Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/torchio/transforms/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def _parse_range(
f'If {name} is a single number, it must be of'
f' type {type_constraint}, not {nums_range}',
)
min_range = -nums_range if min_constraint is None else nums_range
min_range = -nums_range if min_constraint is None else min_constraint
return (min_range, nums_range)

try:
Expand Down
4 changes: 4 additions & 0 deletions tests/transforms/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ def test_arguments_are_and_are_not_dict(self):
with pytest.raises(ValueError):
transform.arguments_are_dict()

def test_min_constraint(self):
transform = tio.RandomNoise()
assert transform._parse_range(3, 'name', min_constraint=0) == (0, 3)

def test_bad_over_max(self):
transform = tio.RandomNoise()
with pytest.raises(ValueError):
Expand Down
Loading