JuliaMath / Interpolations.jl

Fast, continuous interpolation of discrete datasets in Julia
http://juliamath.github.io/Interpolations.jl/
Other
523 stars 110 forks source link

Loading Interpolations.jl breaks complex number arithmetic on Julia 1.8.1 #520

Closed mtenders closed 1 year ago

mtenders commented 1 year ago

Hi,

I'm running Interpolations.jl with Julia 1.8.1. I get an error when I run the following (supposedly) simple code:

julia> using Interpolations

julia> a = Complex[1, 1]
2-element Vector{Complex}:
 1 + 0im
 1 + 0im

julia> b = Complex.([1,1])
2-element Vector{Complex{Int64}}:
 1 + 0im
 1 + 0im

julia> a .* b .- b
ERROR: - not defined for Complex{Int64}
Stacktrace:
 [1] error(::String, ::String, ::Type)
   @ Base ./error.jl:44
 [2] no_op_err(name::String, T::Type)
   @ Base ./promotion.jl:462
 [3] -(x::Complex{Int64}, y::Complex{Int64})
   @ Base ./promotion.jl:465
 [4] _broadcast_getindex_evalf
   @ ./broadcast.jl:670 [inlined]
 [5] _broadcast_getindex
   @ ./broadcast.jl:643 [inlined]
 [6] getindex
   @ ./broadcast.jl:597 [inlined]
 [7] copy
   @ ./broadcast.jl:899 [inlined]
 [8] materialize(bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(-), Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(*), Tuple{Vector{Complex}, Vector{Complex{Int64}}}}, Vector{Complex{Int64}}}})
   @ Base.Broadcast ./broadcast.jl:860
 [9] top-level scope
   @ REPL[4]:1

I tested the same example with Julia 1.7.2 and it seemed to work just fine. Also the following examples don't give me any erros:

julia> a .* b - b
2-element Vector{Complex{Int64}}:
 0 + 0im
 0 + 0im

julia> a .- b
2-element Vector{Complex{Int64}}:
 0 + 0im
 0 + 0im

Everything works normally if I don't load Interpolations in the beginning. Do you have any idea where this is coming from?

mkitti commented 1 year ago

Huh... I'll investigate.

Do I understand correctly that the issue does not occur with Julia 1.7 even if you load Interpolations.jl?

If you have some time, could you try an earlier version of Interpolations.jl to bisect the issue?

mtenders commented 1 year ago

Yes, it does not occur when I load Interpolations.jl in Julia 1.7.

I tried around a bit and I don't get any errors going back to v0.13.3.

Going back to v0.13.3 also downgrades some of the dependencies. They don't get updated automatically going from v0.13.3 to v0.13.4. I only get the error when I upgrade the dependencies to their newest version (see below), after going to v0.13.4.

  [d360d2e6] ↑ ChainRulesCore v0.10.13 ⇒ v1.15.5
  [9e997f8a] + ChangesOfVariables v0.1.4
  [34da2185] ↑ Compat v3.46.0 ⇒ v4.2.0
  [ffbed154] ↑ DocStringExtensions v0.8.6 ⇒ v0.9.1
  [3587e190] + InverseFunctions v0.1.7
  [2ab3a3ac] ↑ LogExpFunctions v0.3.0 ⇒ v0.3.18
  [276daf66] ↑ SpecialFunctions v2.1.3 ⇒ v2.1.7

The problem seems to come from ChainRulesCore.jl. I get the same error, when I just load ChainRulesCore.jl instead of Interpolations.jl.

I filed an issue with them (JuliaDiff/ChainRulesCore.jl/issues/588).

longemen3000 commented 1 year ago

this problem seems solved?

mkitti commented 1 year ago

See https://github.com/JuliaDiff/ChainRulesCore.jl/issues/588