-
Notifications
You must be signed in to change notification settings - Fork 73
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
Test suite and BF for Keithley 485 #285
Test suite and BF for Keithley 485 #285
Conversation
Test suite now includes full coverage. Bug fixes: - Quantities error corrected - If statement for error raising corrected, previous comparison was impossible to achieve - Error catching in `_parse_measurement`. Errors were previously raised in a `try`, `except` statement, however, the wrong error messages would be displayed if these errors in fact got raised
@@ -201,7 +201,7 @@ def input_range(self, newval): | |||
raise ValueError("Only `auto` is acceptable when specifying " | |||
"the range as a string.") | |||
if isinstance(newval, u.Quantity): | |||
newval = float(newval) | |||
newval = float(newval.magnitude) |
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.
Simple correction, would have thrown an error otherwise.
@@ -334,7 +334,7 @@ def _get_status_word(self): | |||
statusword = self.query("U0X") | |||
tries -= 1 | |||
|
|||
if statusword is None: | |||
if tries == 0: |
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.
Above, statusword = ""
is introduced. Then instrument reads are tried several times. statusword
can never be None
. An if statusword
comparison alone furthermore would not do the job in case the instrument returns something invalid. The while loop would still continue in this case until it runs out of tries, and the statusword returned would be bogus.
Checking for tries==0
avoids this issue.
if function != b"DC": | ||
raise ValueError("Instrument not returning DC function: {}".format(function)) | ||
|
||
try: |
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 previous statement tried to get the status, then tried to see what status it is in a try
statement. If one of the if
statements inside the try
pass, they will raise an error, which would jump to the except and raise another error message than the one that should be raised.
Now trying to read to get the statusword from the respective enum class first. If not possible, then raise a respective error. After that we can go into the if statements and check the constraints, if they fail, they will now return the correct error message.
lgtm! |
Test suite now includes full coverage.
Bug fixes:
impossible to achieve
_parse_measurement
. Errors were previously raisedin a
try
,except
statement, however, the wrong error messageswould be displayed if these errors in fact got raised