-
Notifications
You must be signed in to change notification settings - Fork 113
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
Allow rounding with sigdigits #328
base: master
Are you sure you want to change the base?
Conversation
This is a nobrainer to me, and I was looking into trying to fix whatever made the build fail, but that coveralls message is incomprehensible. |
These things always seem noisy. It does say "4 of 4 new or added lines in 1 file covered. (100.0%)" |
bump :) |
I’m not sure I like this, since it is not invariant under unit conversion: julia> x = 2.5u"inch"
2.5 inch
julia> y = uconvert(u"cm", x)
6.35 cm
julia> x == y
true
julia> round(x, sigdigits=2) ≈ round(y, sigdigits=2)
false |
Co-authored-by: Sebastian Stock <[email protected]>
After rounding, shouldn't the test be approximate equality at the resolution you chose? The default is about 8 digits, and you've declared that you don't care about most of them. Of course julia> x = (exp(1))u"inch"
2.718281828459045 inch
julia> y = uconvert(u"cm", x)
6.904435844285975 cm
julia> @test x ≈ round(y, sigdigits=2) rtol=0.01
Test Passed
Expression: ≈(x, round(y, sigdigits = 2), rtol = 0.01)
Evaluated: ≈(2.718281828459045 inch, 6.9 cm; rtol = 0.01)
julia> @test y ≈ round(x, sigdigits=2) rtol=0.01
Test Passed
Expression: ≈(y, round(x, sigdigits = 2), rtol = 0.01)
Evaluated: ≈(6.904435844285975 cm, 2.7 inch; rtol = 0.01)
julia> @test round(x, sigdigits=2) ≈ round(y, sigdigits=2) rtol=0.01
Test Passed
Expression: ≈(round(x, sigdigits = 2), round(y, sigdigits = 2), rtol = 0.01)
Evaluated: ≈(2.7 inch, 6.9 cm; rtol = 0.01) |
It’s a goal of this package that all functionality is unit-invariant. That’s why For However, there are already some non-invariant methods in this package, so I guess one more doesn’t hurt. For example, I really don’t like that |
Co-authored-by: Sebastian Stock <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #328 +/- ##
==========================================
+ Coverage 80.23% 83.74% +3.50%
==========================================
Files 15 16 +1
Lines 1174 1347 +173
==========================================
+ Hits 942 1128 +186
+ Misses 232 219 -13
Continue to review full report at Codecov.
|
Minimal fix for #326