diff --git a/src/torchio/transforms/transform.py b/src/torchio/transforms/transform.py index 93b4f8f7..2375e7ce 100644 --- a/src/torchio/transforms/transform.py +++ b/src/torchio/transforms/transform.py @@ -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: diff --git a/tests/transforms/test_transforms.py b/tests/transforms/test_transforms.py index be99c185..07b6c346 100644 --- a/tests/transforms/test_transforms.py +++ b/tests/transforms/test_transforms.py @@ -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):