Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Backwards compatibility #180

Closed
berceanu opened this issue Oct 10, 2023 · 2 comments
Closed

Backwards compatibility #180

berceanu opened this issue Oct 10, 2023 · 2 comments

Comments

@berceanu
Copy link
Contributor

I am trying to port an older Julia 0.4 code that uses ODE.jl and I find it stumbles on this line

tout, aout = ode45((t,a)->F(t,a, N,p,q,m₀,n₀,J,σ,Ω,κ,f), a₀, [0., 10])

The code is a single, small file. The error I get is:

ERROR: LoadError: MethodError: no method matching Array(::Type{ComplexF64}, ::Int64)

Closest candidates are:
  Array(::LinearAlgebra.UniformScaling, ::Integer, ::Integer)
   @ LinearAlgebra ~/.julia/juliaup/julia-1.9.3+0.aarch64.apple.darwin14/share/julia/stdlib/v1.9/LinearAlgebra/src/uniformscaling.jl:513

Stacktrace:
  [1] F(t::Float64, a::Vector{ComplexF64}, N::Int64, p::Int64, q::Int64, m₀::Int64, n₀::Int64, J::Float64, σ::Float64, Ω::Float64, κ::Float64, f::Vector{Float64})
    @ Main ~/Development/topo-condensate/runge-kutta.jl:27
  [2] (::var"#3#4")(t::Float64, a::Vector{ComplexF64})
    @ Main ~/Development/topo-condensate/runge-kutta.jl:110
  [3] hinit(F::var"#3#4", x0::Vector{ComplexF64}, t0::Float64, tend::Float64, p::Int64, reltol::Float64, abstol::Float64)
    @ ODE ~/.julia/packages/ODE/N5yvz/src/ODE.jl:91
  [4] oderk_adapt(fn::var"#3#4", y0::Vector{ComplexF64}, tspan::Vector{Float64}, btab_::ODE.TableauRKExplicit{:dopri, 7, Rational{Int64}}; reltol::Float64, abstol::Float64, norm::Function, minstep::Float64, maxstep::Float64, initstep::Int64, points::Symbol, alias_u0::Bool)
    @ ODE ~/.julia/packages/ODE/N5yvz/src/runge_kutta.jl:292
  [5] oderk_adapt(fn::Function, y0::Vector{ComplexF64}, tspan::Vector{Float64}, btab_::ODE.TableauRKExplicit{:dopri, 7, Rational{Int64}})
    @ ODE ~/.julia/packages/ODE/N5yvz/src/runge_kutta.jl:232
  [6] #ode45_dp#10
    @ ~/.julia/packages/ODE/N5yvz/src/runge_kutta.jl:221 [inlined]
  [7] ode45_dp
    @ ~/.julia/packages/ODE/N5yvz/src/runge_kutta.jl:221 [inlined]
  [8] #ode45#11
    @ ~/.julia/packages/ODE/N5yvz/src/runge_kutta.jl:223 [inlined]
  [9] ode45(fn::Function, y0::Vector{ComplexF64}, tspan::Vector{Float64})
    @ ODE ~/.julia/packages/ODE/N5yvz/src/runge_kutta.jl:223
 [10] top-level scope
    @ ~/Development/topo-condensate/runge-kutta.jl:110
in expression starting at /Users/berceanu/Development/topo-condensate/runge-kutta.jl:110

Any ideas on how to get this working with the current version of ODE.jl and Julia 1.9?

@ChrisRackauckas
Copy link
Member

https://github.com/berceanu/topo-condensate/blob/56ef99b81c5c24dcacec52cf5839047399db025f/runge-kutta.jl#L26

That syntax is old and changed in Julia v1.0. It's Array{Complex{Float64}}(undef, d) (or zero(Complex{Float64}, d) is probably better).

Let me know if you need anything else.

@berceanu
Copy link
Contributor Author

Thanks!
With this and few other small changes, my script now works on Julia v1.9. 🥳

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants