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
Add Station.close_all_registered_instruments
#1713
Add Station.close_all_registered_instruments
#1713
Conversation
as per our offline discussion, yes :) |
Codecov Report
@@ Coverage Diff @@
## master #1713 +/- ##
==========================================
+ Coverage 67.32% 67.33% +<.01%
==========================================
Files 146 146
Lines 18073 18078 +5
==========================================
+ Hits 12167 12172 +5
Misses 5906 5906 |
Station.close_all_registered_instruments
Station.close_all_registered_instruments
object by calling the :meth:`.base.Instrument.close`-method on | ||
each one. | ||
The instruments will stay registered as a component to the | ||
`Station`. |
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.
Is this still true?
qcodes/station.py
Outdated
@@ -275,10 +275,9 @@ def close_all_registered_instruments(self) -> None: | |||
The instruments will stay registered as a component to the | |||
`Station`. | |||
""" | |||
for k, v in self.components.items(): | |||
if isinstance(v, Instrument): | |||
inst = v |
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.
Out of curiosity, why do inst = v
and then inst.close()
rather than just v.close()
?
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.
this is a style thing. "v" is just a value from a dictionary of components, hence it can be an instrument but also something else. after the isinstance part, the "v" is clarified to be an "inst" instrument, and this is expressed via defining a new variable because closing an instrument is a valid operation, while closing "a component" may not be valid because not all station components are expected to support the "close" method.
Add a method to the Station that closes all instruments that have been registered as a component to the Station.
Open questions: