-
Notifications
You must be signed in to change notification settings - Fork 71
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
convert with same type does not use the correct method #317
Comments
I reproduce both problems on Julia 1.1.1. The second problem is understandable (lack of a method)... |
True, but it only goes there because it does not pick the correct method in line 19... |
This is a weird bug. I don't know why it's happening, but I have a fix in #320. This should probably be reported as a Julia bug. |
Thanks a lot! |
Reported on JuliaLang here: |
This happens with no other packages loaded, so I don't think any dependencies are involved? |
Right, it's just a mystery. |
Jeff answered in the above issue. Did this actually cause any problems for you? |
Yes, because of the EDIT: Here is a simple example to show my problem: julia> using IntervalArithmetic
julia> i = Interval(0//1 ± 1//1)
[-1//1, 1//1]
julia> [i, i]
ERROR: MethodError: no method matching atomic(::Type{Interval{Rational{Int64}}}, ::Interval{Rational{Int64}})
Closest candidates are:
atomic(::Type{Interval{T<:AbstractFloat}}, ::Interval) where T<:AbstractFloat at /.julia/packages/IntervalArithmetic/1T5or/src/intervals/conversion.jl:123
atomic(::Type{Interval{T<:AbstractFloat}}, ::S<:Real) where {T<:AbstractFloat, S<:Real} at /.julia/packages/IntervalArithmetic/1T5or/src/intervals/conversion.jl:96
atomic(::Type{Interval{Rational{Int64}}}, ::Irrational) at /.julia/packages/IntervalArithmetic/1T5or/src/intervals/conversion.jl:133
...
Stacktrace:
[1] convert(::Type{Interval{Rational{Int64}}}, ::Interval{Rational{Int64}}) at /.julia/packages/IntervalArithmetic/1T5or/src/intervals/conversion.jl:20
[2] setindex!(::Array{Interval{Rational{Int64}},1}, ::Interval{Rational{Int64}}, ::Int64) at ./array.jl:767
[3] vect(::Interval{Rational{Int64}}, ::Vararg{Interval{Rational{Int64}},N} where N) at ./array.jl:130
[4] top-level scope at none:0 I still do not understand why this was no problem before, but the fix seems to be easy to do now. |
So, should we restrict the types always? |
Maybe we should restrict the types, but that's a lot of code to work through... |
The |
I noticed a recent problem when converting intervals.
The relevant definitions are here:
IntervalArithmetic.jl/src/intervals/conversion.jl
Lines 19 to 20 in 1516c5e
To me they look correct, and I think until recently they worked as expected. In particular, the first method should fire if source and target type are identical. Below are the results in a fresh environment with Julia v1.2.0-rc2:
So the wrong method is used (the more general one). With
Rational
s this even crashes.I realized this in a recent rebase of a pull request in Julia v1.0 and v1.1. The build was green before, and since this was after your latest release, the problem is probably not on your side. But I am out of ideas.
Note that this works:
The text was updated successfully, but these errors were encountered: