Skip to content

Commit

Permalink
Merge pull request #5447 from jenshnielsen/forward_port_0411
Browse files Browse the repository at this point in the history
Port changes from 0.41.x to main
  • Loading branch information
jenshnielsen authored Oct 19, 2023
2 parents 612c9c9 + cddd553 commit 372cc06
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
8 changes: 8 additions & 0 deletions docs/changes/0.41.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
QCoDeS 0.41.1 (2023-10-19)
==========================

Improved:
---------

- Corrected a bug where non integer step sizes were incorrectly rejected
from parameters without integer validators. (:pr:`5446`)
1 change: 1 addition & 0 deletions docs/changes/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Changelogs

.. toctree::
Unreleased <unreleased>
0.41.1 <0.41.1>
0.41.0 <0.41.0>
0.40.0 <0.40.0>
0.39.1 <0.39.1>
Expand Down
2 changes: 1 addition & 1 deletion src/qcodes/parameters/parameter_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ def step(self, step: float | None) -> None:
self._step = None
elif step <= 0:
raise ValueError("step must be positive")
elif not all(isinstance(vals, Ints) for vals in self._vals) and not isinstance(
elif any(isinstance(vals, Ints) for vals in self._vals) and not isinstance(
step, int
):
raise TypeError("step must be a positive int for an Ints parameter")
Expand Down
18 changes: 17 additions & 1 deletion src/qcodes/tests/parameter/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from hypothesis import given

from qcodes.parameters import Parameter
from qcodes.validators import Ints
from qcodes.validators import Ints, Numbers


def test_add_ints_validator_to_parameter():
Expand Down Expand Up @@ -187,3 +187,19 @@ def test_replace_vals():
p.remove_validator()
p.vals = None
assert len(p.validators) == 0


def test_validators_step_int() -> None:
# this parameter should allow step to be set as a float since the parameter is in it self a float
param = Parameter("a", get_cmd=False, set_cmd=False, vals=Numbers(0, 10))

param.step = 0.1
param.step = 1.0

param.add_validator(Ints(0, 10))

# but once we add an integer validator we no longer can set a step size as a float
with pytest.raises(
TypeError, match="step must be a positive int for an Ints parameter"
):
param.step = 0.1

0 comments on commit 372cc06

Please sign in to comment.