Skip to content

Commit 8f38f3e

Browse files
bors[bot]jenshnielsendependabot[bot]
authored
Merge #4923 #4926
4923: Move VoltageDivider into parameters and deprecate r=jenshnielsen a=jenshnielsen This is not an instrument but a Parameter so it makes more sense for it to live there. Since DelegateParamerer does the same more general and better deprecate this one 4926: Bump pytest-rerunfailures from 10.3 to 11.0 r=jenshnielsen a=dependabot[bot] Bumps [pytest-rerunfailures](https://github.com/pytest-dev/pytest-rerunfailures) from 10.3 to 11.0. <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/pytest-dev/pytest-rerunfailures/blob/master/CHANGES.rst">pytest-rerunfailures's changelog</a>.</em></p> <blockquote> <h2>11.0 (unreleased)</h2> <p>Breaking changes ++++++++++++++++</p> <ul> <li> <p>Drop support for Python 3.6.</p> </li> <li> <p>Drop support for pytest &lt; 6.</p> </li> </ul> <p>Bug fixes +++++++++</p> <ul> <li> <p>Fix crash when pytest-xdist is installed but disabled. (Thanks to <code>`@mgorny` &lt;https://github.com/mgorny&gt;</code>_ for the PR.)</p> </li> <li> <p>Fix crash when xfail(strict=True) mark is used with --rerun-only flag.</p> </li> </ul> <p>Features ++++++++</p> <ul> <li> <p>Added option <code>--rerun-except</code> to rerun failed tests those are other than the mentioned Error.</p> </li> <li> <p>Add support for Python 3.11.</p> </li> <li> <p>Add support for pytest 7.0, 7.1, 7.2.</p> </li> </ul> <h2>10.2 (2021-09-17)</h2> <p>Features ++++++++</p> <ul> <li>Allow recovery from crashed tests with pytest-xdist.</li> <li>Add support for Python 3.10 (as of Python 3.10.rc2). (Thanks to <code>`@hugovk` &lt;https://github.com/hugovk&gt;</code>_ for the PR.)</li> </ul> <h2>10.1 (2021-07-02)</h2> <p>Features ++++++++</p> <ul> <li>Allows using a <code>str</code> as condition for <code>`@pytest.mark.flaky(condition)</code>` which gets evaluated dynamically similarly to <code>`@pytest.mark.skipif(condition)</code>.` (<code>[#162](pytest-dev/pytest-rerunfailures#162) &lt;https://github.com/pytest-dev/pytest-rerunfailures/pull/162&gt;</code>_</li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/pytest-dev/pytest-rerunfailures/commit/4dc493befc4323310b568e461ad184881c0459d1"><code>4dc493b</code></a> Preparing release 11.0</li> <li><a href="https://github.com/pytest-dev/pytest-rerunfailures/commit/3ffda7fad457fd6518915d0c2806b26566ba2b73"><code>3ffda7f</code></a> fix: don't bind all ips (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-rerunfailures/issues/201">#201</a>)</li> <li><a href="https://github.com/pytest-dev/pytest-rerunfailures/commit/737183cb61c279292ed3a19c0b4655e64b0b4040"><code>737183c</code></a> Update dependencies: (<a href="https://github-redirect.dependabot.com/pytest-dev/pytest-rerunfailures/issues/202">#202</a>)</li> <li>See full diff in <a href="https://github.com/pytest-dev/pytest-rerunfailures/compare/10.3...11.0">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pytest-rerunfailures&package-manager=pip&previous-version=10.3&new-version=11.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) You can trigger a rebase of this PR by commenting ``@dependabot` rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - ``@dependabot` rebase` will rebase this PR - ``@dependabot` recreate` will recreate this PR, overwriting any edits that have been made to it - ``@dependabot` merge` will merge this PR after your CI passes on it - ``@dependabot` squash and merge` will squash and merge this PR after your CI passes on it - ``@dependabot` cancel merge` will cancel a previously requested merge and block automerging - ``@dependabot` reopen` will reopen this PR if it is closed - ``@dependabot` close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - ``@dependabot` ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - ``@dependabot` ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - ``@dependabot` ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Co-authored-by: Jens H. Nielsen <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 parents 26e04b4 + 525de1b + 0358aef commit 8f38f3e

File tree

4 files changed

+112
-94
lines changed

4 files changed

+112
-94
lines changed

qcodes/instrument_drivers/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
from .devices import VoltageDivider
1+
from qcodes.parameters.voltage_divider import VoltageDivider
2+
3+
"""
4+
Deprecated alias will be removed
5+
"""

qcodes/instrument_drivers/devices.py

+4-92
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,5 @@
1-
from typing import Optional, Union
1+
"""
2+
Alias for backwards compatiblility. Will be deprecated and removed in a future version of QCoDeS
3+
"""
24

3-
from qcodes.instrument import Instrument
4-
from qcodes.parameters import Parameter
5-
6-
7-
class VoltageDivider(Parameter):
8-
"""
9-
Resitive voltage divider
10-
11-
To be used when you use a physical voltage divider to set or get a voltage.
12-
13-
Initialize the voltage diveder by passing the parameter to be measured
14-
and the value of the division (which should be calibrated beforehand)
15-
16-
>>> vd = VoltageDivider(dac.chan0, 10)
17-
18-
The voltage divider acts a your original parameter, but will set the right
19-
value, and store the division_value in the metadata.
20-
21-
Set the value you want to set your device at 10 V
22-
23-
>>> vd(10)
24-
25-
This will set the dac.cha0 at 10*10, but upon measuring the divider
26-
the value returned is the voltage at the sample.
27-
28-
>>> vd()
29-
10
30-
31-
To get the voltage that was actually set on the instrument:
32-
33-
>>> vd.get_instrument_value()
34-
100
35-
36-
37-
38-
Args:
39-
v1: Parameter physically attached to the divider as input
40-
division_value: the divsion value of the divider
41-
label: label of this parameter, by default uses v1 label
42-
but attaches _attenuated
43-
name: name of this parameter, by default uses v1 name
44-
but attaches _attenuated
45-
"""
46-
47-
def __init__(self,
48-
v1: Parameter,
49-
division_value: Union[int, float],
50-
name: Optional[str] = None,
51-
label: Optional[str] = None,
52-
instrument: Union[None, Instrument] = None) -> None:
53-
self.v1 = v1
54-
self.division_value = division_value
55-
if label:
56-
self.label = label
57-
else:
58-
self.label = f"{self.v1.label}_attenuated"
59-
60-
if not name:
61-
name = f"{self.v1.name}_attenuated"
62-
63-
if not instrument:
64-
instrument = getattr(self.v1, "_instrument", None)
65-
super().__init__(
66-
name=name,
67-
instrument=instrument,
68-
label=self.label,
69-
unit=self.v1.unit,
70-
metadata=self.v1.metadata)
71-
72-
# extend metadata
73-
self._meta_attrs.extend(["division_value"])
74-
75-
def set_raw(self, value: Union[int, float]) -> None:
76-
instrument_value = value * self.division_value
77-
self.v1.set(instrument_value)
78-
79-
def get_raw(self) -> Union[int, float]:
80-
"""
81-
Returns:
82-
value at which was set at the sample
83-
"""
84-
value = self.v1.get() / self.division_value
85-
return value
86-
87-
def get_instrument_value(self) -> Union[int, float]:
88-
"""
89-
Returns:
90-
value at which the attached parameter is (i.e. does
91-
not account for the scaling)
92-
"""
93-
return self.v1.get()
5+
from qcodes.parameters.voltage_divider import VoltageDivider

qcodes/parameters/voltage_divider.py

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
from __future__ import annotations
2+
3+
from typing import TYPE_CHECKING
4+
5+
from qcodes.parameters import Parameter
6+
from qcodes.utils import deprecate
7+
8+
if TYPE_CHECKING:
9+
from qcodes.instrument import Instrument
10+
11+
12+
@deprecate(alternative="DelegateParameter")
13+
class VoltageDivider(Parameter):
14+
"""
15+
Resitive voltage divider
16+
17+
To be used when you use a physical voltage divider to set or get a voltage.
18+
19+
Initialize the voltage diveder by passing the parameter to be measured
20+
and the value of the division (which should be calibrated beforehand)
21+
22+
>>> vd = VoltageDivider(dac.chan0, 10)
23+
24+
The voltage divider acts a your original parameter, but will set the right
25+
value, and store the division_value in the metadata.
26+
27+
Set the value you want to set your device at 10 V
28+
29+
>>> vd(10)
30+
31+
This will set the dac.cha0 at 10*10, but upon measuring the divider
32+
the value returned is the voltage at the sample.
33+
34+
>>> vd()
35+
10
36+
37+
To get the voltage that was actually set on the instrument:
38+
39+
>>> vd.get_instrument_value()
40+
100
41+
42+
43+
44+
Args:
45+
v1: Parameter physically attached to the divider as input
46+
division_value: the divsion value of the divider
47+
label: label of this parameter, by default uses v1 label
48+
but attaches _attenuated
49+
name: name of this parameter, by default uses v1 name
50+
but attaches _attenuated
51+
"""
52+
53+
def __init__(
54+
self,
55+
v1: Parameter,
56+
division_value: int | float,
57+
name: str | None = None,
58+
label: str | None = None,
59+
instrument: None | Instrument = None,
60+
) -> None:
61+
self.v1 = v1
62+
self.division_value = division_value
63+
if label:
64+
self.label = label
65+
else:
66+
self.label = f"{self.v1.label}_attenuated"
67+
68+
if not name:
69+
name = f"{self.v1.name}_attenuated"
70+
71+
if not instrument:
72+
instrument = getattr(self.v1, "_instrument", None)
73+
super().__init__(
74+
name=name,
75+
instrument=instrument,
76+
label=self.label,
77+
unit=self.v1.unit,
78+
metadata=self.v1.metadata,
79+
)
80+
81+
# extend metadata
82+
self._meta_attrs.extend(["division_value"])
83+
84+
def set_raw(self, value: int | float) -> None:
85+
instrument_value = value * self.division_value
86+
self.v1.set(instrument_value)
87+
88+
def get_raw(self) -> int | float:
89+
"""
90+
Returns:
91+
value at which was set at the sample
92+
"""
93+
value = self.v1.get() / self.division_value
94+
return value
95+
96+
def get_instrument_value(self) -> int | float:
97+
"""
98+
Returns:
99+
value at which the attached parameter is (i.e. does
100+
not account for the scaling)
101+
"""
102+
return self.v1.get()

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pytest-asyncio==0.20.3
116116
pytest-cov~=4.0.0
117117
pytest-forked~=1.4.0
118118
pytest-mock~=3.10.0
119-
pytest-rerunfailures==10.3
119+
pytest-rerunfailures==11.0
120120
pytest-xdist~=3.1.0
121121
python-dateutil~=2.8.2
122122
pytz~=2022.5

0 commit comments

Comments
 (0)