Skip to content

Commit 47d7f5f

Browse files
authored
Merge pull request #7187 from jenshnielsen/lakeshore_cleanup
Lakeshore driver improvments
2 parents 141c570 + 096e70e commit 47d7f5f

16 files changed

Lines changed: 159 additions & 64 deletions
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The deprecated aliases to Lakeshore modules in `qcodes.instrument_drivers.Lakeshore.lakeshore_base` have been removed.
2+
The aliases to lakeshore drivers in `qcodes.instrument_drivers.Lakeshore.Model_325`, `qcodes.instrument_drivers.Lakeshore.Model_336` and `qcodes.instrument_drivers.Lakeshore.Model_372`
3+
have been removed. Please make sure that all Lakeshore related imports are from `qcodes.instrument_drivers.Lakeshore` avoiding any submodules.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ filterwarnings = [
238238
'ignore:unclosed database in:ResourceWarning', # internal should be fixed
239239
'ignore:ConnectionPlus is deprecated:qcodes.utils.deprecate.QCoDeSDeprecationWarning', # remove once deprecated ConnectionPlus has been removed
240240
'ignore:make_connection_plus_from is deprecated:qcodes.utils.deprecate.QCoDeSDeprecationWarning', # remove once deprecated ConnectionPlus has been removed
241+
'ignore:Model_336 is deprecated:qcodes.utils.deprecate.QCoDeSDeprecationWarning', # remove once deprecated Lakeshore Model_336 and its tests has been removed
241242
]
242243

243244
[tool.ruff]

src/qcodes/instrument_drivers/Lakeshore/Lakeshore_model_325.py

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
from typing_extensions import Buffer, Unpack
2828

29+
from qcodes.instrument.channel import ChannelTuple
30+
2931

3032
def _read_curve_file(curve_file: TextIO) -> dict[Any, Any]:
3133
"""
@@ -583,31 +585,53 @@ def __init__(
583585
self, "sensor", LakeshoreModel325Sensor, snapshotable=False
584586
)
585587

586-
for inp in ["A", "B"]:
587-
sensor = LakeshoreModel325Sensor(self, f"sensor_{inp}", inp)
588-
sensors.append(sensor)
589-
self.add_submodule(f"sensor_{inp}", sensor)
588+
self.sensor_A: LakeshoreModel325Sensor = self.add_submodule(
589+
"sensor_A", LakeshoreModel325Sensor(self, "sensor_A", "A")
590+
)
591+
"""Sensor A"""
592+
sensors.append(self.sensor_A)
593+
self.sensor_B: LakeshoreModel325Sensor = self.add_submodule(
594+
"sensor_B", LakeshoreModel325Sensor(self, "sensor_B", "B")
595+
)
596+
"""Sensor B"""
597+
sensors.append(self.sensor_B)
590598

591-
self.add_submodule("sensor", sensors.to_channel_tuple())
599+
self.sensor: ChannelTuple[LakeshoreModel325Sensor] = self.add_submodule(
600+
"sensor", sensors.to_channel_tuple()
601+
)
602+
"""ChannelTuple of sensors"""
592603

593604
heaters = ChannelList(
594605
self, "heater", LakeshoreModel325Heater, snapshotable=False
595606
)
596607

597-
for loop in [1, 2]:
598-
heater = LakeshoreModel325Heater(self, f"heater_{loop}", loop)
599-
heaters.append(heater)
600-
self.add_submodule(f"heater_{loop}", heater)
608+
self.heater_1: LakeshoreModel325Heater = self.add_submodule(
609+
"heater_1", LakeshoreModel325Heater(self, "heater_1", 1)
610+
)
611+
"""Heater 1"""
612+
heaters.append(self.heater_1)
601613

602-
self.add_submodule("heater", heaters.to_channel_tuple())
614+
self.heater_2: LakeshoreModel325Heater = self.add_submodule(
615+
"heater_2", LakeshoreModel325Heater(self, "heater_2", 2)
616+
)
617+
"""Heater 2"""
618+
heaters.append(self.heater_2)
619+
620+
self.heater: ChannelTuple[LakeshoreModel325Heater] = self.add_submodule(
621+
"heater", heaters.to_channel_tuple()
622+
)
623+
"""ChannelTuple of heaters"""
603624

604625
curves = ChannelList(self, "curve", LakeshoreModel325Curve, snapshotable=False)
605626

606627
for curve_index in range(1, 35):
607628
curve = LakeshoreModel325Curve(self, curve_index)
608629
curves.append(curve)
609630

610-
self.add_submodule("curve", curves)
631+
self.curve: ChannelList[LakeshoreModel325Curve] = self.add_submodule(
632+
"curve", curves
633+
)
634+
"""ChannelList of curves"""
611635

612636
self.connect_message()
613637

src/qcodes/instrument_drivers/Lakeshore/Lakeshore_model_336.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,31 @@ def __init__(
294294
) -> None:
295295
super().__init__(name, address, **kwargs)
296296

297-
self.output_1 = LakeshoreModel336CurrentSource(self, "output_1", 1)
298-
self.output_2 = LakeshoreModel336CurrentSource(self, "output_2", 2)
299-
self.output_3 = LakeshoreModel336VoltageSource(self, "output_3", 3)
300-
self.output_4 = LakeshoreModel336VoltageSource(self, "output_4", 4)
297+
self.output_1: LakeshoreModel336CurrentSource = self.add_submodule(
298+
name="output_1",
299+
submodule=LakeshoreModel336CurrentSource(self, "output_1", 1),
300+
)
301+
"""
302+
Control output 1 of Lakeshore Model 336.
303+
"""
304+
self.output_2: LakeshoreModel336CurrentSource = self.add_submodule(
305+
name="output_2",
306+
submodule=LakeshoreModel336CurrentSource(self, "output_2", 2),
307+
)
308+
"""
309+
Control output 2 of Lakeshore Model 336.
310+
"""
311+
self.output_3: LakeshoreModel336VoltageSource = self.add_submodule(
312+
name="output_3",
313+
submodule=LakeshoreModel336VoltageSource(self, "output_3", 3),
314+
)
315+
"""
316+
Control output 3 of Lakeshore Model 336.
317+
"""
318+
self.output_4: LakeshoreModel336VoltageSource = self.add_submodule(
319+
name="output_4",
320+
submodule=LakeshoreModel336VoltageSource(self, "output_4", 4),
321+
)
322+
"""
323+
Control output 4 of Lakeshore Model 336.
324+
"""

src/qcodes/instrument_drivers/Lakeshore/Lakeshore_model_372.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,25 @@ def __init__(
350350
super().__init__(name, address, **kwargs)
351351

352352
heaters = {"sample_heater": 0, "warmup_heater": 1, "analog_heater": 2}
353-
for heater_name, heater_index in heaters.items():
354-
self.add_submodule(
355-
heater_name, LakeshoreModel372Output(self, heater_name, heater_index)
356-
)
353+
354+
self.sample_heater: LakeshoreModel372Output = self.add_submodule(
355+
"sample_heater",
356+
LakeshoreModel372Output(self, "sample_heater", heaters["sample_heater"]),
357+
)
358+
"""
359+
Sample heater output channel.
360+
"""
361+
self.warmup_heater: LakeshoreModel372Output = self.add_submodule(
362+
"warmup_heater",
363+
LakeshoreModel372Output(self, "warmup_heater", heaters["warmup_heater"]),
364+
)
365+
"""
366+
Warm-up heater output channel.
367+
"""
368+
self.analog_heater: LakeshoreModel372Output = self.add_submodule(
369+
"analog_heater",
370+
LakeshoreModel372Output(self, "analog_heater", heaters["analog_heater"]),
371+
)
372+
"""
373+
Analog heater output channel.
374+
"""

src/qcodes/instrument_drivers/Lakeshore/Model_325.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88
from itertools import takewhile
99
from typing import TYPE_CHECKING, Any, Optional, TextIO, cast
1010

11+
from typing_extensions import deprecated
12+
1113
from qcodes.instrument import (
1214
ChannelList,
1315
InstrumentChannel,
1416
VisaInstrument,
1517
VisaInstrumentKWArgs,
1618
)
1719
from qcodes.parameters import Group, GroupParameter
20+
from qcodes.utils import QCoDeSDeprecationWarning
1821
from qcodes.validators import Enum, Numbers
1922

2023
from .Lakeshore_model_325 import LakeshoreModel325Curve as Model_325_Curve
@@ -28,6 +31,11 @@
2831
from typing_extensions import Unpack
2932

3033

34+
@deprecated(
35+
"Model_325 is deprecated. Please use qcodes.instrument_drivers.Lakeshore.LakeshoreModel325 instead.",
36+
category=QCoDeSDeprecationWarning,
37+
stacklevel=1,
38+
)
3139
class Model_325(VisaInstrument):
3240
"""
3341
Lakeshore Model 325 Temperature Controller Driver

src/qcodes/instrument_drivers/Lakeshore/Model_336.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55

66
from typing import TYPE_CHECKING, Any, ClassVar
77

8+
from typing_extensions import deprecated
9+
810
import qcodes.validators as vals
911
from qcodes.parameters import Group, GroupParameter
12+
from qcodes.utils import QCoDeSDeprecationWarning
1013

11-
from .lakeshore_base import (
12-
BaseOutput, # pyright: ignore
13-
BaseSensorChannel, # pyright: ignore
14-
LakeshoreBase,
15-
)
14+
from .lakeshore_base import LakeshoreBase
15+
from .lakeshore_base import LakeshoreBaseOutput as BaseOutput
16+
from .lakeshore_base import LakeshoreBaseSensorChannel as BaseSensorChannel
1617
from .Lakeshore_model_336 import LakeshoreModel336Channel as Model_336_Channel
1718
from .Lakeshore_model_336 import (
1819
LakeshoreModel336CurrentSource as Output_336_CurrentSource,
@@ -28,6 +29,11 @@
2829
from qcodes.instrument import VisaInstrumentKWArgs
2930

3031

32+
@deprecated(
33+
"Model_336 is deprecated. Please use qcodes.instrument_drivers.Lakeshore.LakeshoreModel336 instead.",
34+
category=QCoDeSDeprecationWarning,
35+
stacklevel=1,
36+
)
3137
class Model_336(LakeshoreBase):
3238
"""
3339
Lakeshore Model 336 Temperature Controller Driver

src/qcodes/instrument_drivers/Lakeshore/Model_372.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,20 @@
55

66
from typing import TYPE_CHECKING, Any, ClassVar
77

8+
from typing_extensions import deprecated
9+
810
import qcodes.validators as vals
911
from qcodes.instrument_drivers.Lakeshore.lakeshore_base import (
10-
BaseOutput, # pyright: ignore
11-
BaseSensorChannel, # pyright: ignore
1212
LakeshoreBase,
1313
)
14+
from qcodes.instrument_drivers.Lakeshore.lakeshore_base import (
15+
LakeshoreBaseOutput as BaseOutput,
16+
)
17+
from qcodes.instrument_drivers.Lakeshore.lakeshore_base import (
18+
LakeshoreBaseSensorChannel as BaseSensorChannel,
19+
)
1420
from qcodes.parameters import Group, GroupParameter
21+
from qcodes.utils import QCoDeSDeprecationWarning
1522

1623
from .Lakeshore_model_372 import LakeshoreModel372Channel as Model_372_Channel
1724
from .Lakeshore_model_372 import LakeshoreModel372Output as Output_372
@@ -25,6 +32,11 @@
2532
_n_channels = 16
2633

2734

35+
@deprecated(
36+
"Model_372 is deprecated. Please use qcodes.instrument_drivers.Lakeshore.LakeshoreModel372 instead.",
37+
category=QCoDeSDeprecationWarning,
38+
stacklevel=1,
39+
)
2840
class Model_372(LakeshoreBase):
2941
"""
3042
Lakeshore Model 372 Temperature Controller Driver

src/qcodes/instrument_drivers/Lakeshore/_lakeshore_model_335.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,19 @@ def __init__(
206206
self.visa_handle.data_bits = 7
207207
self.visa_handle.parity = pyvisa.constants.Parity(1)
208208

209-
self.output_1 = LakeshoreModel335CurrentSource(self, "output_1", 1)
210-
self.output_2 = LakeshoreModel335CurrentSource(self, "output_2", 2)
209+
self.output_1: LakeshoreModel335CurrentSource = self.add_submodule(
210+
name="output_1",
211+
submodule=LakeshoreModel335CurrentSource(self, "output_1", 1),
212+
)
213+
"""
214+
An InstrumentChannel for the first current source of Lakeshore Model 335.
215+
"""
216+
self.output_2 = self.add_submodule(
217+
name="output_2",
218+
submodule=LakeshoreModel335CurrentSource(self, "output_2", 2),
219+
)
220+
"""
221+
An InstrumentChannel for the second current source of Lakeshore Model 335.
222+
"""
211223

212224
self.connect_message()

src/qcodes/instrument_drivers/Lakeshore/lakeshore_base.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import TYPE_CHECKING, Any, ClassVar, Generic
44

55
import numpy as np
6-
from typing_extensions import TypeVar, deprecated
6+
from typing_extensions import TypeVar
77

88
from qcodes import validators as vals
99
from qcodes.instrument import (
@@ -14,13 +14,14 @@
1414
VisaInstrumentKWArgs,
1515
)
1616
from qcodes.parameters import Group, GroupParameter, Parameter
17-
from qcodes.utils import QCoDeSDeprecationWarning
1817

1918
if TYPE_CHECKING:
2019
from collections.abc import Sequence
2120

2221
from typing_extensions import Unpack
2322

23+
from qcodes.instrument.channel import ChannelTuple
24+
2425

2526
class LakeshoreBaseOutput(InstrumentChannel):
2627
MODES: ClassVar[dict[str, int]] = {}
@@ -505,15 +506,6 @@ def wait_until_set_point_reached(
505506
time.sleep(wait_cycle_time)
506507

507508

508-
@deprecated(
509-
"Base class renamed to LakeshoreBaseOutput",
510-
category=QCoDeSDeprecationWarning,
511-
stacklevel=2,
512-
)
513-
class BaseOutput(LakeshoreBaseOutput):
514-
pass
515-
516-
517509
class LakeshoreBaseSensorChannel(InstrumentChannel):
518510
# A dictionary of sensor statuses that assigns a string representation of
519511
# the status to a status bit weighting (e.g. {4: 'VMIX OVL'})
@@ -668,15 +660,6 @@ def _get_sum_terms(available_terms: "Sequence[int]", number: int) -> list[int]:
668660
return terms_in_number
669661

670662

671-
@deprecated(
672-
"Base class renamed to LakeshoreBaseSensorChannel",
673-
category=QCoDeSDeprecationWarning,
674-
stacklevel=2,
675-
)
676-
class BaseSensorChannel(LakeshoreBaseSensorChannel):
677-
pass
678-
679-
680663
ChanType_co = TypeVar(
681664
"ChanType_co",
682665
bound=LakeshoreBaseSensorChannel,
@@ -742,7 +725,9 @@ def __init__(
742725
channel = self.CHANNEL_CLASS(self, channel_name, command)
743726
channels.append(channel)
744727
self.add_submodule(channel_name, channel)
745-
self.channels = self.add_submodule("channels", channels.to_channel_tuple())
728+
self.channels: ChannelTuple[ChanType_co] = self.add_submodule(
729+
"channels", channels.to_channel_tuple()
730+
)
746731
"""A ChannelTuple of sensor channels on the Lakeshore instrument."""
747732

748733
# on Model335 we need to change serial port settings

0 commit comments

Comments
 (0)