Skip to content
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

MethodError: no method matching setindex(::Vector{Float64}, ::Float64, ::Int64) #911

Closed
pjssilva opened this issue Nov 6, 2022 · 1 comment

Comments

@pjssilva
Copy link

pjssilva commented Nov 6, 2022

The following code is a small variation of the code that appear in the help of ODEProblem (One parameter of the ODE is different, the lorenz function is not inplace, and it does not specify the Tsit5() solver):

using DifferentialEquations
function lorenz(u, p, t)
    d1 = 10.0(u[2] - u[1])
    d2 = u[1] * (10.0 - u[3]) - u[2]
    d3 = u[1] * u[2] - (8 / 3) * u[3]
    return [d1, d2, d3]
end
u0 = [1.0; 0.0; 0.0]
tspan = (0.0, 100.0)
prob = ODEProblem(lorenz, u0, tspan)

# Test that it worked
sol = solve(prob)

It crashes with MethodError: no method matching setindex(::Vector{Float64}, ::Float64, ::Int64). The error actually happens in the line 196 of the file jacobian.jl of the FiniteDiff.jl package. It seems that it is expecting a tuple (for which setindex is defined) but gets a Vector (for which only setindex! is defined). If I change setindex to setindex! in that point, the error disapears. But I am not sure whether the problem is in DifferentialEquations.jl that is sending a Vector in place of a Tuple of in FiniteDiff.jl.

@ChrisRackauckas
Copy link
Member

Thanks, there was a hiccup in the system but on latest packages this is fixed.

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

No branches or pull requests

2 participants