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

Throw a nicer error if eltype is not a number #976

Merged
merged 2 commits into from
Dec 16, 2023
Merged

Conversation

ChrisRackauckas
Copy link
Member

julia>  solve(prob,Tsit5())
ERROR: Non-Number element type inside of an `Array` detected.
Arrays with non-number element types, such as
`Array{Array{Float64}}`, are not supported by the
solvers.

If you are trying to use an array of arrays structure,
look at the tools in RecursiveArrayTools.jl. For example:

If this was a mistake, promote the element types to be
all the same. If this was intentional, for example,
using Unitful.jl with different unit values, then use
an array type which has fast broadcast support for
heterogeneous values such as the ArrayPartition
from RecursiveArrayTools.jl. For example:

```julia
using RecursiveArrayTools
u0 = ArrayPartition([1.0,2.0],[3.0,4.0])
u0 = VectorOfArray([1.0,2.0],[3.0,4.0])

are both initial conditions which would be compatible with
the solvers.

Element type:
Matrix{Float64}

Some of the types have been truncated in the stacktrace for improved reading. To emit complete information
in the stack trace, evaluate TruncatedStacktraces.VERBOSE[] = true and re-run the code.

Stacktrace:
[1] solve_call(_prob::ODEProblem{…}, args::Tsit5{…}; merge_callbacks::Bool, kwargshandle::Nothing, kwargs::@kwargs{})
@ DiffEqBase c:\Users\accou.julia\dev\DiffEqBase\src\solve.jl:591
[2] solve_call(_prob::ODEProblem{…}, args::Tsit5{…})
@ DiffEqBase c:\Users\accou.julia\dev\DiffEqBase\src\solve.jl:565
[3] solve_up(prob::ODEProblem{…}, sensealg::Nothing, u0::Vector{…}, p::SciMLBase.NullParameters, args::Tsit5{…}; kwargs::@kwargs{})
@ DiffEqBase C:\Users\accou.julia\packages\DiffEqBase\a6p43\src\solve.jl:1010
[4] solve_up(prob::ODEProblem{…}, sensealg::Nothing, u0::Vector{…}, p::SciMLBase.NullParameters, args::Tsit5{…})
@ DiffEqBase C:\Users\accou.julia\packages\DiffEqBase\a6p43\src\solve.jl:996
[5] solve(prob::ODEProblem{…}, args::Tsit5{…}; sensealg::Nothing, u0::Nothing, p::Nothing, wrap::Val{…}, kwargs::@kwargs{})
@ DiffEqBase C:\Users\accou.julia\packages\DiffEqBase\a6p43\src\solve.jl:933
[6] solve(prob::ODEProblem{…}, args::Tsit5{…})
@ DiffEqBase C:\Users\accou.julia\packages\DiffEqBase\a6p43\src\solve.jl:923
[7] top-level scope
@ REPL[5]:1
Some type information was truncated. Use show(err) to see complete types.

@ChrisRackauckas ChrisRackauckas merged commit 2b6140e into master Dec 16, 2023
31 of 39 checks passed
@ChrisRackauckas ChrisRackauckas deleted the numbertype branch December 16, 2023 15:57
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

Successfully merging this pull request may close these issues.

1 participant