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 Oct 7, 2024
1 parent 7ae35ab commit 7abe68c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/device_object.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ in the function call of measurement scripts, you can set the argument priorize_s
Another important feature is the possibility to save and load device working points. To store a certain configuration as your default working point,
use device.save_defaults. This stores all parameter values (of parameters that can be set). With device.set_defaults() you can reset it to the stored
configuration. Alternatively you can use "device.save_state(name)" and "device.set_state(name)" to store and set multiple working points with
custom names. They can also be accessed via "device.states" in case you forgot the name.
custom names. They can also be accessed via "device.states" in case you forgot the name.
For all of those methods the parameters are ramped to the final state by default (with the default QuMada ramp rate). You can use the argument "ramp = False" to avoid this, or use keyword
arguments (ramp_rate, duration) to adjust the ramp speed when calling the methods. Alternatively, you can set the parameter "device.ramp" to True or False in order to control the behaviour
for the complete device.
Expand Down
18 changes: 9 additions & 9 deletions src/qumada/measurement/device_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def update_terminal_parameters(self):
for param in mapping.keys():
self.terminals[terminal].update_terminal_parameter(param)

def save_defaults(self, ramp = None, **kwargs):
def save_defaults(self, ramp=None, **kwargs):

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

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L86

Added line #L86 was not covered by tests
"""
Saves current values as default for all Terminals and their parameters
"""
Expand All @@ -97,28 +97,28 @@ def save_state(self, name: str):
"""
self.states[name] = self.save_to_dict(priorize_stored_value=False)

def set_state(self, name: str, ramp = None, **kwargs):
def set_state(self, name: str, ramp=None, **kwargs):
if ramp is None:
ramp = self.ramp

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

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L100-L102

Added lines #L100 - L102 were not covered by tests
self.load_from_dict(self.states[name])
self.set_stored_values(ramp = ramp, **kwargs)
self.set_stored_values(ramp=ramp, **kwargs)

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

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L104

Added line #L104 was not covered by tests

def set_stored_values(self, ramp = None, **kwargs):
def set_stored_values(self, ramp=None, **kwargs):
if ramp is None:
ramp = self.ramp

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

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L106-L108

Added lines #L106 - L108 were not covered by tests
for terminal in self.terminals.values():
for param in terminal.terminal_parameters.values():
param.set_stored_value()

def set_defaults(self, ramp = None, **kwargs):
def set_defaults(self, ramp=None, **kwargs):

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

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L113

Added line #L113 was not covered by tests
"""
Sets all Terminals and their parameters to their default values
"""
if ramp is None:
ramp = self.ramp

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

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L117-L118

Added lines #L117 - L118 were not covered by tests
for terminal in self.terminals.values():
for param in terminal.terminal_parameters.values():
param.set_default(ramp = ramp, **kwargs)
param.set_default(ramp=ramp, **kwargs)

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

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L121

Added line #L121 was not covered by tests

def voltages(self):
"""
Expand Down Expand Up @@ -686,7 +686,7 @@ def save_default(self):
logger.warning(f"{e} was raised when trying to save default value of {self.name}")
pass

def set_default(self, ramp = True, **kwargs):
def set_default(self, ramp=True, **kwargs):

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

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L689

Added line #L689 was not covered by tests
"""
Sets value to default value
"""
Expand All @@ -701,7 +701,7 @@ def set_default(self, ramp = True, **kwargs):
else:
logger.warning(f"No default value set for parameter {self.name}")

def set_stored_value(self, ramp = True, **kwargs):
def set_stored_value(self, ramp=True, **kwargs):

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

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L704

Added line #L704 was not covered by tests
"""
Sets value to stored value from dict
"""
Expand All @@ -716,7 +716,7 @@ def set_stored_value(self, ramp = True, **kwargs):
else:
logger.warning(f"No stored value set for parameter {self.name}")

def __call__(self, value=None, ramp = None):
def __call__(self, value=None, ramp=None):

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

View check run for this annotation

Codecov / codecov/patch

src/qumada/measurement/device_object.py#L719

Added line #L719 was not covered by tests
if value is None:
return self.value
else:
Expand Down
5 changes: 2 additions & 3 deletions src/qumada/utils/ramp_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import logging
import time

from math import isclose

from qumada.utils.generate_sweeps import generate_sweep
Expand Down Expand Up @@ -73,7 +72,7 @@ def ramp_parameter(
Not used yet. The default is "all".
tolerance: float, optional
If abs(current_value- target_value) < tolerance*max(current_value, target_value)
no ramp is done. Default 1e-5.
no ramp is done. Default 1e-5.
**kwargs : TYPE
DESCRIPTION.
Expand All @@ -99,7 +98,7 @@ def ramp_parameter(

if isinstance(current_value, float):
LOG.debug(f"target: {target}")
if isclose(current_value, target, rel_tol = tolerance):
if isclose(current_value, target, rel_tol=tolerance):
LOG.debug("Target value is sufficiently close to current_value, no need to ramp")
return True

Check warning on line 103 in src/qumada/utils/ramp_parameter.py

View check run for this annotation

Codecov / codecov/patch

src/qumada/utils/ramp_parameter.py#L101-L103

Added lines #L101 - L103 were not covered by tests

Expand Down

0 comments on commit 7abe68c

Please sign in to comment.