-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parameter set to improvements #1749
Parameter set to improvements #1749
Conversation
595919f
to
f3652d6
Compare
Codecov Report
@@ Coverage Diff @@
## master #1749 +/- ##
=========================================
Coverage ? 67.59%
=========================================
Files ? 146
Lines ? 18266
Branches ? 0
=========================================
Hits ? 12346
Misses ? 5920
Partials ? 0 |
qcodes/instrument/parameter.py
Outdated
self._value_is_changing = self._value != self._original_value | ||
|
||
if self._original_value is None and self._value_is_changing: | ||
self._original_value = self._parameter.get() # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following the merge of #1738 please don't use bare ignores. use --show-error-codes
to get the error code needed and do ignore[errorcode]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha!
This PR fixes a bug in
parameter.set_to
and reduces the amount of instrument communication (calls toparameter.set
) that happens in the context manager.The bugfix: if a parameter has been initialized, but not yet gotten, it will have a
_latest["value"]
ofNone
. When exiting the context manager, the value that the parameter is restored to should not beNone
, but instead the result ofparameter.get
.The improvement: if
parameter
has valueX
, thenwith parameter.set_to(X)
is now a NOOP.The improvement allows us to write parameter getters that hinge on other parameters without introducing unnecessary communication. An example (simplified) for a DMM that can be in voltage or current mode:
Imagine getting the voltage or current in a tight loop. In that case, we do not want the communication to be
for each get call.
@QCoDeS/core