Skip to content

Commit

Permalink
Remove deprecated channel aliases channel_a, channel_b ... from MiniC…
Browse files Browse the repository at this point in the history
…ircuitsUsbSPDT drivers

Use the names a, b ... instead
  • Loading branch information
jenshnielsen committed Jun 27, 2024
1 parent 72fb25e commit 140b3cd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 38 deletions.
14 changes: 7 additions & 7 deletions src/qcodes/instrument_drivers/AlazarTech/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ class in some way.

class CapabilityHelper:
"""
A helper class providing convenient methods for various useful
'query capability' (``AlazarQueryCapability``) calls for a given
Alazar board.
A helper class providing convenient methods for various useful
'query capability' (``AlazarQueryCapability``) calls for a given
Alazar board.
Most common capabilities are enumerated in :attr:`.CAPABILITIES`.
For frequently used capabilities, dedicated convenience ``query_<...>()``
methods are available.
For frequently used capabilities, dedicated convenience ``query_<...>()``
methods are available.
Args:
api: Instance of Alazar ATS API class
handle: Handle of a specific board (from ``AlazarGetBoardBySystemId``)
api: Instance of Alazar ATS API class
handle: Handle of a specific board (from ``AlazarGetBoardBySystemId``)
"""

CAPABILITIES = Capability
Expand Down
24 changes: 2 additions & 22 deletions src/qcodes/instrument_drivers/Minicircuits/Base_SPDT.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import logging
import re
import warnings
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING

from typing_extensions import deprecated

Expand Down Expand Up @@ -92,39 +91,20 @@ def add_channels(self) -> None:
channels = ChannelList(
self, "Channels", self.CHANNEL_CLASS, snapshotable=False)

_chanlist = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
self._deprecated_attributes: dict[str, str] = {
f'channel_{k}': k
for k in _chanlist
}

_chanlist = ["a", "b", "c", "d", "e", "f", "g", "h"]
_max_channel_number = self.get_number_of_channels()
_chanlist = _chanlist[0:_max_channel_number]

for c in _chanlist:
channel = self.CHANNEL_CLASS(self, f'channel_{c}', c)
channels.append(channel)
attribute_name = f'channel_{c}'
self.add_submodule(attribute_name, channel)
self.add_submodule(c, channel)
self._deprecated_attributes[attribute_name] = c
self.add_submodule("channels", channels.to_channel_tuple())

def all(self, switch_to: int) -> None:
for c in self.channels:
c.switch(switch_to)

def __getattr__(self, key: str) -> Any:
if key in self._deprecated_attributes:
warnings.warn(
(
f"Using '{key}' is deprecated and will be removed in future"
f"releases. Use '{self._deprecated_attributes[key]}' instead"
),
UserWarning,
)
return super().__getattr__(key)

def get_number_of_channels(self) -> int:
model = self.get_idn()['model']
if model is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,12 @@ def __init__(
Mini-Circuits SPDT RF switch
Args:
name: the name of the instrument
driver_path: path to the dll
serial_number: the serial number of the device
(printed on the sticker on the back side, without s/n)
kwargs: kwargs to be passed to Instrument class.
name: the name of the instrument
driver_path: path to the dll
serial_number: the serial number of the device
(printed on the sticker on the back side, without s/n)
kwargs: kwargs to be passed to Instrument class.
"""
# we are eventually overwriting this but since it's called
# in __getattr__ of `SPDT_Base` it's important that it's
# always set to something to avoid infinite recursion
self._deprecated_attributes = {}
# import .net exception so we can catch it below
# we keep this import local so that the module can be imported
# without a working .net install
Expand Down

0 comments on commit 140b3cd

Please sign in to comment.