Skip to content

Commit

Permalink
Merge #4923 #4927
Browse files Browse the repository at this point in the history
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

4927: Update pyzmq requirement from ~=24.0.1 to ~=25.0.0 r=jenshnielsen a=dependabot[bot]

Updates the requirements on [pyzmq](https://github.com/zeromq/pyzmq) to permit the latest version.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/zeromq/pyzmq/commit/8e4e5c80dc16ecaed06d9c95e4947bae478a6177"><code>8e4e5c8</code></a> Bump to 25.0.0</li>
<li><a href="https://github.com/zeromq/pyzmq/commit/e4d380d0ff6de36674084d5899dcfa29dcfd656a"><code>e4d380d</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/zeromq/pyzmq/issues/1819">#1819</a> from minrk/cl-25</li>
<li><a href="https://github.com/zeromq/pyzmq/commit/cab205f49f71eaa5ff9783f5907ca4685e90dd57"><code>cab205f</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/zeromq/pyzmq/issues/1824">#1824</a> from zeromq/pre-commit-ci-update-config</li>
<li><a href="https://github.com/zeromq/pyzmq/commit/f2757ebcc23b91e32b2dfa5a6d0b3ebca7914d9f"><code>f2757eb</code></a> [pre-commit.ci] pre-commit autoupdate</li>
<li><a href="https://github.com/zeromq/pyzmq/commit/917bb884a3ce68fb7ccff95edb02c0f8e0025bcd"><code>917bb88</code></a> note manylinux_2_28 wheels in changelog</li>
<li><a href="https://github.com/zeromq/pyzmq/commit/5666a79661b4f0087e9c9bac9b9331317b86381f"><code>5666a79</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/zeromq/pyzmq/issues/1822">#1822</a> from minrk/cp311-2014</li>
<li><a href="https://github.com/zeromq/pyzmq/commit/a64ec0624c367e3b0d34256032d3dad4fd3f7024"><code>a64ec06</code></a> publish both 2014 and 2_28 wheels for cpython &gt;= 3.10, pypy &gt;= 3.9</li>
<li><a href="https://github.com/zeromq/pyzmq/commit/f5e17f8a250287433265f830646376aa7517a5e6"><code>f5e17f8</code></a> update changelog for 25</li>
<li><a href="https://github.com/zeromq/pyzmq/commit/25545d43ba8be95d27f1215c11a03ff811c92072"><code>25545d4</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/zeromq/pyzmq/issues/1818">#1818</a> from minrk/deprecate-test</li>
<li><a href="https://github.com/zeromq/pyzmq/commit/22d0cfd049cb4c93ca41ef0089f65a68c5cfb0bd"><code>22d0cfd</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/zeromq/pyzmq/issues/1817">#1817</a> from minrk/toml-syntax</li>
<li>Additional commits viewable in <a href="https://github.com/zeromq/pyzmq/compare/v24.0.1...v25.0.0">compare view</a></li>
</ul>
</details>
<br />


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 <Jens.Nielsen@microsoft.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Jan 13, 2023
3 parents e5a72a9 + 525de1b + 711cf7a commit 06f7b03
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 94 deletions.
6 changes: 5 additions & 1 deletion qcodes/instrument_drivers/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
from .devices import VoltageDivider
from qcodes.parameters.voltage_divider import VoltageDivider

"""
Deprecated alias will be removed
"""
96 changes: 4 additions & 92 deletions qcodes/instrument_drivers/devices.py
Original file line number Diff line number Diff line change
@@ -1,93 +1,5 @@
from typing import Optional, Union
"""
Alias for backwards compatiblility. Will be deprecated and removed in a future version of QCoDeS
"""

from qcodes.instrument import Instrument
from qcodes.parameters import Parameter


class VoltageDivider(Parameter):
"""
Resitive voltage divider
To be used when you use a physical voltage divider to set or get a voltage.
Initialize the voltage diveder by passing the parameter to be measured
and the value of the division (which should be calibrated beforehand)
>>> vd = VoltageDivider(dac.chan0, 10)
The voltage divider acts a your original parameter, but will set the right
value, and store the division_value in the metadata.
Set the value you want to set your device at 10 V
>>> vd(10)
This will set the dac.cha0 at 10*10, but upon measuring the divider
the value returned is the voltage at the sample.
>>> vd()
10
To get the voltage that was actually set on the instrument:
>>> vd.get_instrument_value()
100
Args:
v1: Parameter physically attached to the divider as input
division_value: the divsion value of the divider
label: label of this parameter, by default uses v1 label
but attaches _attenuated
name: name of this parameter, by default uses v1 name
but attaches _attenuated
"""

def __init__(self,
v1: Parameter,
division_value: Union[int, float],
name: Optional[str] = None,
label: Optional[str] = None,
instrument: Union[None, Instrument] = None) -> None:
self.v1 = v1
self.division_value = division_value
if label:
self.label = label
else:
self.label = f"{self.v1.label}_attenuated"

if not name:
name = f"{self.v1.name}_attenuated"

if not instrument:
instrument = getattr(self.v1, "_instrument", None)
super().__init__(
name=name,
instrument=instrument,
label=self.label,
unit=self.v1.unit,
metadata=self.v1.metadata)

# extend metadata
self._meta_attrs.extend(["division_value"])

def set_raw(self, value: Union[int, float]) -> None:
instrument_value = value * self.division_value
self.v1.set(instrument_value)

def get_raw(self) -> Union[int, float]:
"""
Returns:
value at which was set at the sample
"""
value = self.v1.get() / self.division_value
return value

def get_instrument_value(self) -> Union[int, float]:
"""
Returns:
value at which the attached parameter is (i.e. does
not account for the scaling)
"""
return self.v1.get()
from qcodes.parameters.voltage_divider import VoltageDivider
102 changes: 102 additions & 0 deletions qcodes/parameters/voltage_divider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from qcodes.parameters import Parameter
from qcodes.utils import deprecate

if TYPE_CHECKING:
from qcodes.instrument import Instrument


@deprecate(alternative="DelegateParameter")
class VoltageDivider(Parameter):
"""
Resitive voltage divider
To be used when you use a physical voltage divider to set or get a voltage.
Initialize the voltage diveder by passing the parameter to be measured
and the value of the division (which should be calibrated beforehand)
>>> vd = VoltageDivider(dac.chan0, 10)
The voltage divider acts a your original parameter, but will set the right
value, and store the division_value in the metadata.
Set the value you want to set your device at 10 V
>>> vd(10)
This will set the dac.cha0 at 10*10, but upon measuring the divider
the value returned is the voltage at the sample.
>>> vd()
10
To get the voltage that was actually set on the instrument:
>>> vd.get_instrument_value()
100
Args:
v1: Parameter physically attached to the divider as input
division_value: the divsion value of the divider
label: label of this parameter, by default uses v1 label
but attaches _attenuated
name: name of this parameter, by default uses v1 name
but attaches _attenuated
"""

def __init__(
self,
v1: Parameter,
division_value: int | float,
name: str | None = None,
label: str | None = None,
instrument: None | Instrument = None,
) -> None:
self.v1 = v1
self.division_value = division_value
if label:
self.label = label
else:
self.label = f"{self.v1.label}_attenuated"

if not name:
name = f"{self.v1.name}_attenuated"

if not instrument:
instrument = getattr(self.v1, "_instrument", None)
super().__init__(
name=name,
instrument=instrument,
label=self.label,
unit=self.v1.unit,
metadata=self.v1.metadata,
)

# extend metadata
self._meta_attrs.extend(["division_value"])

def set_raw(self, value: int | float) -> None:
instrument_value = value * self.division_value
self.v1.set(instrument_value)

def get_raw(self) -> int | float:
"""
Returns:
value at which was set at the sample
"""
value = self.v1.get() / self.division_value
return value

def get_instrument_value(self) -> int | float:
"""
Returns:
value at which the attached parameter is (i.e. does
not account for the scaling)
"""
return self.v1.get()
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ PyVISA-sim==0.5.1
pywin32==305; sys_platform == 'win32'
pywinpty~=2.0.8; sys_platform == 'win32'
PyYAML==6.0
pyzmq~=24.0.1
pyzmq~=25.0.0
requests~=2.28.1
rsa==4.9
ruamel.yaml==0.17.21
Expand Down

0 comments on commit 06f7b03

Please sign in to comment.