Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.14.14
rev: v0.15.0
hooks:
- id: ruff-check
types_or: [python, pyi, jupyter, toml]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@
"metadata": {},
"outputs": [],
"source": [
"noise = Parameter(\n",
" \"noise\", label=\"Position\", unit=\"m\", get_cmd=lambda: np.random.randn()\n",
")\n",
"noise = Parameter(\"noise\", label=\"Position\", unit=\"m\", get_cmd=np.random.randn)\n",
"time = ElapsedTimeParameter(\"time\")"
]
},
Expand Down
4 changes: 2 additions & 2 deletions src/qcodes/dataset/data_set_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import warnings
from collections.abc import Callable, Mapping, Sequence
from enum import Enum
from enum import StrEnum
from importlib.metadata import entry_points
from pathlib import Path
from typing import (
Expand Down Expand Up @@ -555,6 +555,6 @@ def dependent_parameters(self) -> tuple[ParamSpecBase, ...]:
return tuple(self.description.interdeps.dependencies.keys())


class DataSetType(str, Enum):
class DataSetType(StrEnum):
DataSet = "DataSet"
DataSetInMem = "DataSetInMem"
2 changes: 1 addition & 1 deletion src/qcodes/instrument/delegate/instrument_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(
super().__init__(name=name, **kwargs)

module_name = ".".join(submodules_type.split(".")[:-1])
instr_class_name = submodules_type.split(".")[-1]
instr_class_name = submodules_type.rsplit(".", maxsplit=1)[-1]
module = importlib.import_module(module_name)
instr_class = getattr(module, instr_class_name)

Expand Down
2 changes: 1 addition & 1 deletion src/qcodes/instrument_drivers/QDev/QDac_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def _num_verbose(self, s: str) -> float:
value descriptor.
"""
if self.verbose.get_latest():
s = s.split(": ")[-1]
s = s.rsplit(": ", maxsplit=1)[-1]
return float(s)

def _current_parser(self, s: str) -> float:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ def __init__(
"enabled",
label="Switch Heater Enabled",
get_cmd=self._check_enabled,
set_cmd=lambda x: (self._enable() if x else self._disable()),
set_cmd=lambda x: self._enable() if x else self._disable(),
vals=Bool(),
)
"""Parameter enabled"""
self.state: Parameter = self.add_parameter(
"state",
label="Switch Heater On",
get_cmd=self._check_state,
set_cmd=lambda x: (self._on() if x else self._off()),
set_cmd=lambda x: self._on() if x else self._off(),
vals=Bool(),
)
"""Parameter state. Always False is the switch heater is not enabled"""
Expand Down Expand Up @@ -262,8 +262,8 @@ def __init__(
"""Parameter current_ramp_limit"""
self.field_ramp_limit: Parameter = self.add_parameter(
"field_ramp_limit",
get_cmd=lambda: self.current_ramp_limit(),
set_cmd=lambda x: self.current_ramp_limit(x),
get_cmd=self.current_ramp_limit,
set_cmd=self.current_ramp_limit,
scale=1 / float(self.ask("COIL?")),
unit="T/s",
)
Expand Down
2 changes: 1 addition & 1 deletion src/qcodes/instrument_drivers/oxford/MercuryiPS_VISA.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def _temp_parser(response: str) -> float:
response: What comes back from instrument.ask

"""
return float(response.split(":")[-1][:-1])
return float(response.rsplit(":", maxsplit=1)[-1][:-1])


class OxfordMercuryWorkerPS(InstrumentChannel):
Expand Down
10 changes: 5 additions & 5 deletions src/qcodes/instrument_drivers/oxford/triton.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def _get_control_Bcomp_param(self, param: str) -> float | str | list[float] | No
return self._get_response_value(self.ask(cmd[:-2]) + cmd[-2:])

def _get_response(self, msg: str) -> str:
return msg.split(":")[-1]
return msg.rsplit(":", maxsplit=1)[-1]

def _get_response_value(self, msg: str) -> float | str | list[float] | None:
msg = self._get_response(msg)
Expand Down Expand Up @@ -551,12 +551,12 @@ def _parse_time(self, msg: str) -> str:
def _parse_temp(self, msg: str) -> float | None:
if "NOT_FOUND" in msg:
return None
return float(msg.split("SIG:TEMP:")[-1].strip("K"))
return float(msg.rsplit("SIG:TEMP:", maxsplit=1)[-1].strip("K"))

def _parse_pres(self, msg: str) -> float | None:
if "NOT_FOUND" in msg:
return None
return float(msg.split("SIG:PRES:")[-1].strip("mB")) * 1e3
return float(msg.rsplit("SIG:PRES:", maxsplit=1)[-1].strip("mB")) * 1e3

def _recv(self) -> str:
return super()._recv().rstrip()
Expand All @@ -579,7 +579,7 @@ def _set_pump_state(self, pump: str, state: str) -> None:
def _get_parser_pump_speed(self, msg: str) -> float | None:
if "NOT_FOUND" in msg:
return None
return float(msg.split("SPD:")[-1].strip("Hz"))
return float(msg.rsplit("SPD:", maxsplit=1)[-1].strip("Hz"))

def _add_temp_state(self) -> None:
for i in range(1, 17):
Expand All @@ -599,7 +599,7 @@ def _set_temp_state(self, chan: str, state: str) -> None:
def _get_parser_state(self, key: str, msg: str) -> str | None:
if "NOT_FOUND" in msg:
return None
return msg.split(f"{key}:")[-1]
return msg.rsplit(f"{key}:", maxsplit=1)[-1]


Triton = OxfordTriton
Expand Down
8 changes: 5 additions & 3 deletions src/qcodes/instrument_drivers/rigol/Rigol_DG1062.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,11 @@ def __init__(
vals.Enum("INF", "MIN", "MAX", "HighZ"),
),
get_parser=(
lambda value: "HighZ"
if float(value) > RigolDG1062Channel.max_impedance
else float(value)
lambda value: (
"HighZ"
if float(value) > RigolDG1062Channel.max_impedance
else float(value)
)
),
set_parser=lambda value: "INF" if value == "HighZ" else value,
)
Expand Down
2 changes: 1 addition & 1 deletion src/qcodes/instrument_drivers/tektronix/AWG5014.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def __init__(
get_cmd="AWGControl:SEQuencer:POSition?",
set_cmd="SEQuence:JUMP:IMMediate {}",
vals=vals.PermissiveInts(1),
set_parser=lambda x: round(x),
set_parser=round,
)
"""Parameter sequence_pos"""

Expand Down
6 changes: 3 additions & 3 deletions src/qcodes/interactive_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,9 +536,9 @@ def experiments_widget(
elif sort_by == "timestamp":
data_sets = sorted(
data_sets,
key=lambda ds: ds.run_timestamp_raw
if ds.run_timestamp_raw is not None
else 0,
key=lambda ds: (
ds.run_timestamp_raw if ds.run_timestamp_raw is not None else 0
),
reverse=True,
)

Expand Down
2 changes: 1 addition & 1 deletion tests/dataset/test_dataset_in_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ def test_dataset_in_mem_with_inferred_parameters(
inferred2 = ManualParameter("inferred2", initial_value=0.0)
control1 = ManualParameter("control1", initial_value=0.0)
control2 = ManualParameter("control2", initial_value=0.0)
dependent = Parameter("dependent", get_cmd=lambda: control1(), set_cmd=False)
dependent = Parameter("dependent", get_cmd=control1, set_cmd=False)
meas = Measurement(exp=experiment, name="via Measurement")

meas.register_parameter(control1)
Expand Down
4 changes: 2 additions & 2 deletions tests/parameter/test_parameter_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_setting_int_with_float() -> None:
name="foobar",
set_cmd=None,
get_cmd=None,
set_parser=lambda x: round(x),
set_parser=round,
vals=vals.PermissiveInts(0),
)

Expand All @@ -65,7 +65,7 @@ def test_setting_int_with_float_not_close() -> None:
name="foobar",
set_cmd=None,
get_cmd=None,
set_parser=lambda x: round(x),
set_parser=round,
vals=vals.PermissiveInts(0),
)

Expand Down
6 changes: 3 additions & 3 deletions tests/test_autoloadable_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ def __init__(self) -> None:
self._greetings = {chn: "Hello" for chn in self._channel_catalog}

self._command_dict = {
r":INST:CHN(\d):HLO": lambda chn: self._greetings[chn]
+ " from channel "
+ str(chn),
r":INST:CHN(\d):HLO": lambda chn: (
f"{self._greetings[chn]} from channel {chn}"
),
r":INST:CHN:ADD (\d), (.+)": self._add_channel,
r":INST:CHN:DEL (\d)": self._channel_catalog.remove,
r":INST:CHN:CAT": lambda: ",".join(str(i) for i in self._channel_catalog),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_visa.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def write(
) -> int:
if self.closed:
raise RuntimeError("Trying to write to a closed instrument")
num = float(message.split(":")[-1])
num = float(message.rsplit(":", maxsplit=1)[-1])
self.state = num

if num < 0:
Expand Down
Loading