diff --git a/src/zhinst/toolkit/driver/parsers.py b/src/zhinst/toolkit/driver/parsers.py index d9fa131f..595eedc6 100644 --- a/src/zhinst/toolkit/driver/parsers.py +++ b/src/zhinst/toolkit/driver/parsers.py @@ -98,6 +98,10 @@ def multiple_of(value: float, factor: float, rounding: str) -> float: Returns: Rounded value. + + .. versionchanged:: 0.5.3 + + Invalid `rounding` value raises `ValueError` instead of `RuntimeError`. """ if abs(round(value / factor) * factor - value) < 1e-12: return value @@ -117,7 +121,7 @@ def multiple_of(value: float, factor: float, rounding: str) -> float: f"multiple: {v_rounded:.3e}", ) return v_rounded - raise RuntimeError( + raise ValueError( f"Invalid rounding type {rounding} only the " "following values are allowed: [nearest,down]" ) diff --git a/tests/test_parsers.py b/tests/test_parsers.py index 9f29e057..2a846a44 100644 --- a/tests/test_parsers.py +++ b/tests/test_parsers.py @@ -40,5 +40,5 @@ def test_multiple_of(self, caplog): assert len(caplog.records) == 2 assert Parse.multiple_of(12, 6, "down") == 12 assert len(caplog.records) == 2 - with pytest.raises(RuntimeError): + with pytest.raises(ValueError): Parse.multiple_of(100, 6, "up")