Skip to content
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

Merged

Conversation

Dominik-Vogel
Copy link
Contributor

Add a method to the Station that closes all instruments that have been registered as a component to the Station.
Open questions:

  • should Instruments also be removed from the station?

@astafan8
Copy link
Contributor

astafan8 commented Sep 11, 2019

should Instruments also be removed from the station?

as per our offline discussion, yes :)

@codecov
Copy link

codecov bot commented Sep 14, 2019

Codecov Report

Merging #1713 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #1713      +/-   ##
==========================================
+ Coverage   67.32%   67.33%   +<.01%     
==========================================
  Files         146      146              
  Lines       18073    18078       +5     
==========================================
+ Hits        12167    12172       +5     
  Misses       5906     5906

@Dominik-Vogel Dominik-Vogel changed the title [WIP] Add Station.close_all_registered_instruments Add Station.close_all_registered_instruments Sep 18, 2019
qcodes/station.py Outdated Show resolved Hide resolved
object by calling the :meth:`.base.Instrument.close`-method on
each one.
The instruments will stay registered as a component to the
`Station`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still true?

@@ -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
Copy link
Contributor

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()?

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants