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 better support for floating point multiple_of values #652
Add better support for floating point multiple_of values #652
Conversation
Codecov Report
@@ Coverage Diff @@
## master #652 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 15 15
Lines 2651 2655 +4
Branches 524 526 +2
=====================================
+ Hits 2651 2655 +4 |
While working on this I noticed that JSONSchema spec says mutliple_of must strictly be greater than 0.0, so I added a validation error and a test for this behavior. |
You're checking v not Also your calling |
Oof, yeah. Is there a more appropriate place to check this then? Somewhere maybe it could be an error during declaration rather than at validation time? I reverted the extra validation commit for the time being. |
(on my mobile) Yes, they're better places, probably in |
@samuelcolvin FYI I'm not planning on following up with the |
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.
LGTM 🎉
LGTM, @justindujardin please could you rebase and move the new history line to the new section. I'm aware the history thing is getting annoying I'll try to adopt towncrier or similar soon. |
- modulo doesn't work with floating point values in many cases, e.g. `0.3 % 0.1 == 0.09999999999999998` - port implementation from: tdegrunt/jsonschema#187 (comment) - add tests for int/float multiple_of values - update history with pr/author
@samuelcolvin sure thing, done |
Change Summary
Add support for multiple_of with arbitrary int/floating point numbers. The current implementation fails for obvious floating point values, e.g.
0.3
fails to validate as a multiple of0.1
.Related issue number
None
Checklist
HISTORY.rst
has been updated#<number>
@<whomever>