-
Notifications
You must be signed in to change notification settings - Fork 347
Add function to instrument to validate all gettable parameters #347
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,7 +53,8 @@ def setUpClass(cls): | |
|
|
||
| cls.gates = MockGates(model=cls.model, server_name='') | ||
| cls.source = MockSource(model=cls.model, server_name='') | ||
| cls.meter = MockMeter(model=cls.model, keep_history=False, server_name='') | ||
| cls.meter = MockMeter( | ||
| model=cls.model, keep_history=False, server_name='') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this acutally good PEP8 ? model should be aligned with the ( , no ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My autopep8 formatter says its fine
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cool |
||
|
|
||
| def setUp(self): | ||
| # reset the model state via the gates function | ||
|
|
@@ -963,6 +964,14 @@ def tearDown(self): | |
| # TODO (giulioungaretti) remove ( does nothing ?) | ||
| pass | ||
|
|
||
| def test_validate_function(self): | ||
| instrument = self.instrument | ||
| instrument.validate_status() # test the instrument has valid values | ||
|
|
||
| instrument.dac1._save_val(1000) # overrule the validator | ||
| with self.assertRaises(Exception): | ||
| instrument.validate_status() | ||
|
|
||
| def test_attr_access(self): | ||
| instrument = self.instrument | ||
|
|
||
|
|
@@ -975,7 +984,7 @@ def test_attr_access(self): | |
| instrument.close() | ||
|
|
||
| # make sure we can still print the instrument | ||
| s = instrument.__repr__() | ||
| _ = instrument.__repr__() | ||
|
|
||
| # make sure the gate is removed | ||
| self.assertEqual(hasattr(instrument, 'dac1'), False) | ||
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.
I'd prefer verbose to be a real bool, than the 0 (which suggests a level of verbosity rather than a switch. ).
And what happens if the parameter is gettable, but not settable ?
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.
The
verboseparameter is an int on purpose. In general I use the convetion: 0: no output, 1: normal output, >=2: used for debugging, output not stableThere 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.
If the parameter is gettable but not settable, then nothing happens. The assumption here is that if there is no
.set, then there is probably no meaningfull.validate.If we want we can remove the check on
has_set, since every parameter has a.validatefunction.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.
a) Cool, just write the assumption in the docstring !
b) In this function 2 and 1 are the same then, which I don't like, and I don't see it documented or understandable from the code.
Change to true and false in this case.
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.
@giulioungaretti Ok, changes have been done in #369 which points to
https://github.com/VandersypenQutech/Qcodes/tree/origin/feat/validate_status