Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed May 15, 2024
1 parent 4f36769 commit 8229ade
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions src/qumada/measurement/device_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,16 @@ def save_to_dict(self, priorize_stored_value=False):
return_dict[terminal_name] = {}
for param_name, param in terminal.terminal_parameters.items():
return_dict[terminal_name][param_name] = {}
for attr_name in ["type", "setpoints", "delay", "start", "stop", "num_points", "break_conditions", "limits"]:
for attr_name in [

Check warning on line 163 in src/qumada/measurement/device_object.py

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L159-L163

Added lines #L159 - L163 were not covered by tests
"type",
"setpoints",
"delay",
"start",
"stop",
"num_points",
"break_conditions",
"limits",
]:
if hasattr(param, attr_name):
return_dict[terminal.name][param.name][attr_name] = getattr(param, attr_name)
if priorize_stored_value:
Expand Down Expand Up @@ -416,7 +425,6 @@ def value(self, value):
self._parent_device.update_terminal_parameters()
self.instrument_parameter(value)

Check warning on line 426 in src/qumada/measurement/device_object.py

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L422-L426

Added lines #L422 - L426 were not covered by tests


@value.getter
def value(self):

Check warning on line 429 in src/qumada/measurement/device_object.py

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L428-L429

Added lines #L428 - L429 were not covered by tests
# TODO: Replace Try/Except block, update_terminal_parameters() should be called by mapping function
Expand All @@ -437,27 +445,25 @@ def instrument_parameter(self, param: Parameter):
self.set_limits()

Check warning on line 445 in src/qumada/measurement/device_object.py

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L441-L445

Added lines #L441 - L445 were not covered by tests
else:
raise TypeError(f"{param} is not a QCoDeS parameter!")

Check warning on line 447 in src/qumada/measurement/device_object.py

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L447

Added line #L447 was not covered by tests
@property

@property
def limits(self):
return self._limits

Check warning on line 451 in src/qumada/measurement/device_object.py

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L449-L451

Added lines #L449 - L451 were not covered by tests



@limits.setter
def limits(self, limits):
if type(limits) in (list, tuple) and len(limits) == 2:
self._limits = limits
self._set_limits()

Check warning on line 457 in src/qumada/measurement/device_object.py

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L453-L457

Added lines #L453 - L457 were not covered by tests
else:
raise ValueError("Limits has to be a list|tuple with two entries")

Check warning on line 459 in src/qumada/measurement/device_object.py

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L459

Added line #L459 was not covered by tests



def _set_limits(self):

Check warning on line 461 in src/qumada/measurement/device_object.py

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L461

Added line #L461 was not covered by tests
"""
Uses QCoDeS parameter's validators to limit values of parameters with
number value to the values set in the limits attribute.
Will replace last validator of corresponding parameter, if it was set
by this method before! Won't remove validators that existed before
by this method before! Won't remove validators that existed before
initialization of the parameter. Make sure not to add validators
manually to avoid problem (QCoDeS can only remove the last added
validator, so it's not possible to just remove the correct one.')
Expand All @@ -468,14 +474,15 @@ def _set_limits(self):
raise ValueError(f"Invalid limits provided for {self._parent.name} {self.name}")
param = self.instrument_parameter
if not isinstance(param, Parameter):
logger.exception(f"Cannot set limits to {self._parent.name} {self.name} \
as no valid instrument parameter was assigned to it!")
logger.exception(

Check warning on line 477 in src/qumada/measurement/device_object.py

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L471-L477

Added lines #L471 - L477 were not covered by tests
f"Cannot set limits to {self._parent.name} {self.name} \
as no valid instrument parameter was assigned to it!"
)
else:
if self._limit_validator in param.validators:
param.remove_validator()
self._limit_validator = Numbers(min_value = min(self.limits), max_value = max(self.limits))
param.add_validator(self._limit_validator)

self._limit_validator = Numbers(min_value=min(self.limits), max_value=max(self.limits))
param.add_validator(self._limit_validator)

Check warning on line 485 in src/qumada/measurement/device_object.py

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L482-L485

Added lines #L482 - L485 were not covered by tests

def ramp(self, value, ramp_rate: float = 0.1, ramp_time: float = 5, setpoint_intervall: float = 0.01):
ramp_or_set_parameter(

Check warning on line 488 in src/qumada/measurement/device_object.py

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L487-L488

Added lines #L487 - L488 were not covered by tests
Expand Down

0 comments on commit 8229ade

Please sign in to comment.