Skip to content

Commit 6ed680b

Browse files
jenshnielsenCopilot
andcommitted
Use typed kwargs in CopperMountain M5xxx parameter subclasses
Update FrequencySweepMagPhase, PointMagPhase, and PointIQ to use Unpack[ParameterBaseKWArgs] with concrete CopperMountainM5xxx instrument type, extracting instrument via kwargs.get() + assert for label building before super().__init__(). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent fe7f3e2 commit 6ed680b

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

  • src/qcodes/instrument_drivers/CopperMountain

src/qcodes/instrument_drivers/CopperMountain/_M5xxx.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import TYPE_CHECKING, Any, Literal
1+
from typing import TYPE_CHECKING, Literal
22

33
import numpy as np
44
from numpy.typing import NDArray
@@ -8,6 +8,7 @@
88
ManualParameter,
99
MultiParameter,
1010
Parameter,
11+
ParameterBaseKWArgs,
1112
ParamRawDataType,
1213
create_on_off_val_mapping,
1314
)
@@ -637,9 +638,9 @@ def __init__(
637638
start: float,
638639
stop: float,
639640
number_of_points: int,
640-
instrument: CopperMountainM5xxx,
641+
*,
641642
expected_measurement_duration: float = 600,
642-
**kwargs: Any,
643+
**kwargs: "Unpack[ParameterBaseKWArgs[tuple[NDArray, NDArray], CopperMountainM5xxx]]",
643644
) -> None:
644645
"""
645646
Linear frequency sweep that returns magnitude and phase for a single
@@ -650,17 +651,18 @@ def __init__(
650651
start: Start frequency of linear sweep
651652
stop: Stop frequency of linear sweep
652653
number_of_points: Number of points of linear sweep
653-
instrument: Instrument to which sweep is bound to.
654654
expected_measurement_duration: Adjusts instrument timeout (seconds). Defaults to 600 seconds.
655-
**kwargs: Any
655+
**kwargs: Keyword arguments forwarded to MultiParameter.
656656
657657
"""
658658

659659
self.expected_measurement_duration = expected_measurement_duration
660660

661+
instrument = kwargs.get("instrument")
662+
assert instrument is not None
663+
661664
super().__init__(
662665
name,
663-
instrument=instrument,
664666
names=(
665667
f"{instrument.short_name}_{name}_magnitude",
666668
f"{instrument.short_name}_{name}_phase",
@@ -746,26 +748,27 @@ class PointMagPhase(
746748
def __init__(
747749
self,
748750
name: str,
749-
instrument: CopperMountainM5xxx,
751+
*,
750752
expected_measurement_duration: float = 600,
751-
**kwargs: Any,
753+
**kwargs: "Unpack[ParameterBaseKWArgs[tuple[np.floating, np.floating], CopperMountainM5xxx]]",
752754
) -> None:
753755
"""Magnitude and phase measurement of a single point at start
754756
frequency.
755757
756758
Args:
757759
name: Name of point measurement
758-
instrument: Instrument to which parameter is bound to.
759760
expected_measurement_duration: Adjusts instrument timeout (seconds). Defaults to 600 seconds.
760-
**kwargs: Any
761+
**kwargs: Keyword arguments forwarded to MultiParameter.
761762
762763
"""
763764

764765
self.expected_measurement_duration = expected_measurement_duration
765766

767+
instrument = kwargs.get("instrument")
768+
assert instrument is not None
769+
766770
super().__init__(
767771
name,
768-
instrument=instrument,
769772
names=(
770773
f"{instrument.short_name}_{name}_magnitude",
771774
f"{instrument.short_name}_{name}_phase",
@@ -844,26 +847,27 @@ class PointIQ(MultiParameter[tuple[np.floating, np.floating], CopperMountainM5xx
844847
def __init__(
845848
self,
846849
name: str,
847-
instrument: CopperMountainM5xxx,
850+
*,
848851
expected_measurement_duration: float = 600,
849-
**kwargs: Any,
852+
**kwargs: "Unpack[ParameterBaseKWArgs[tuple[np.floating, np.floating], CopperMountainM5xxx]]",
850853
) -> None:
851854
"""I and Q measurement of a single point at start
852855
frequency.
853856
854857
Args:
855858
name: Name of point measurement
856-
instrument: Instrument to which parameter is bound to.
857859
expected_measurement_duration: Adjusts instrument timeout (seconds). Defaults to 600 seconds.
858-
**kwargs: Any
860+
**kwargs: Keyword arguments forwarded to MultiParameter.
859861
860862
"""
861863

862864
self.expected_measurement_duration = expected_measurement_duration
863865

866+
instrument = kwargs.get("instrument")
867+
assert instrument is not None
868+
864869
super().__init__(
865870
name,
866-
instrument=instrument,
867871
names=(
868872
f"{instrument.short_name}_{name}_i",
869873
f"{instrument.short_name}_{name}_q",

0 commit comments

Comments
 (0)