-
Notifications
You must be signed in to change notification settings - Fork 4
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
change promotion in rational conversion #49
Conversation
Test failure seems unrelated |
Yes, they are due to JuliaLang/julia#48735. |
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.
Some comments:
- There should be a test for this. I would just define a singleton type
One <: Integer
that represents the number 1, that way we don’t need to add OddEvenIntegers.jl as a test dependency. - This only fixes the behavior on Julia 1.5 and newer. On older Julia versions, the following method is used, which still calls
oftype(tx, 2)
:
HalfIntegers.jl/src/HalfIntegers.jl
Line 65 in 215556a
(T::Type{<:Rational})(x::HalfInteger) = (tx=twice(x); T(tx,oftype(tx,2)))
Since both HalfIntegers.jl and OddEvenIntegers.jl support Julia 1.0, I think we should change that method as well. - This change allows
Rational{Int}(half(Odd(1)))
, but notRational(half(Odd(1)))
. For that, the following line would need to be changed as well:
HalfIntegers.jl/src/HalfIntegers.jl
Line 53 in 215556a
Base.unsafe_rational(tx, oftype(tx, 2))
Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>
Codecov ReportPatch coverage:
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## master #49 +/- ##
=======================================
Coverage 99.20% 99.20%
=======================================
Files 1 1
Lines 250 250
=======================================
Hits 248 248
Misses 2 2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@sostock I've added tests and implemented the changes as suggested |
Co-authored-by: Sebastian Stock <42280794+sostock@users.noreply.github.com>
Gentle bump |
This lets one use an odd integer type as the numerator, which can't store
2
. After this, one may use https://github.com/jishnub/OddEvenIntegers.jl to obtainThis errors on master at present