-
Notifications
You must be signed in to change notification settings - Fork 319
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
Validators/permissive multiples #852
Conversation
qcodes/tests/test_validators.py
Outdated
print(div, mult) | ||
val.validate(mult) | ||
|
||
# finally, a quick test that the precision is indeed setable |
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.
Where ?
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.
Woops... nice catch.
divs = int(divmod(value, self.divisor)[0]) | ||
true_vals = np.array([n*self.divisor for n in range(divs, divs+2)]) | ||
abs_errs = [abs(tv-value) for tv in true_vals] | ||
if min(abs_errs) > self.precision: |
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.
Should this have a relative tolerance too?
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.
Mimicking np.allclose
? I am a bit undecided. I think for most cases it will suffice to say "be precise to within 0.5 nV".
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.
Yes as long as people are not using "strange" units its fine, we can always add later if needed
2 Inline comments otherwise looks good |
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.
Just waiting for travis
Author: William H.P. Nielsen <whpn@mailbox.org> Validators/permissive multiples (#852)
Author: William H.P. Nielsen <whpn@mailbox.org> Validators/permissive multiples (#852)
Fixes #765
Changes proposed in this pull request:
The new validator,
PermissiveMultiples
allows integer multiples of a given base value to slip through. It allows negative multiples as well, and therefore by definition always 0. It is subject to rounding errors, so a user-specificied absolute precision is in principle required.@jenshnielsen