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

Bad error message for empty arrays of symbolic indexes #396

Closed
BenChung opened this issue Jul 5, 2024 · 0 comments · Fixed by SciML/SciMLBase.jl#814
Closed

Bad error message for empty arrays of symbolic indexes #396

BenChung opened this issue Jul 5, 2024 · 0 comments · Fixed by SciML/SciMLBase.jl#814
Assignees
Labels

Comments

@BenChung
Copy link

BenChung commented Jul 5, 2024

Describe the bug 🐞
If you index into a result array with an idxs=[] you get the following error message:

> sol(ts, idxs=SymbolicUtils.BasicSymbolic{Real}[])
ERROR: LoadError: Indexing with parameters is deprecated. Use `getp(A, SymbolicUtils.BasicSymbolic{Real}[])` for parameter indexing.
Stacktrace:
  [1] _getindex
    @ C:\Users\benchung\.julia\packages\RecursiveArrayTools\VAOZn\src\vector_of_array.jl:374 [inlined]
....

This is very undesirable, since it does not accurately communicate the problem. Simply returning an empty vector would be the preferred result. The version with a literal empty array is even worse:

julia> sol([0.5], idxs=[])
ERROR: MethodError: no method matching _getindex(::RecursiveArrayTools.DiffEqArray{…}, ::SymbolicIndexingInterface.NotSymbolic, ::Vector{…})

Closest candidates are:
  _getindex(::RecursiveArrayTools.AbstractVectorOfArray{T, N}, ::SymbolicIndexingInterface.NotSymbolic, ::Colon...) where {T<:Number, N}
   @ RecursiveArrayTools C:\Users\benchung\.julia\packages\RecursiveArrayTools\VAOZn\src\vector_of_array.jl:309
  _getindex(::RecursiveArrayTools.AbstractVectorOfArray{T, N}, ::SymbolicIndexingInterface.NotSymbolic, ::Colon...) where {T, N}
   @ RecursiveArrayTools C:\Users\benchung\.julia\packages\RecursiveArrayTools\VAOZn\src\vector_of_array.jl:298
  _getindex(::RecursiveArrayTools.AbstractVectorOfArray{T, N}, ::SymbolicIndexingInterface.NotSymbolic, ::AbstractArray{Bool}, Colon...) where {T, N}
   @ RecursiveArrayTools C:\Users\benchung\.julia\packages\RecursiveArrayTools\VAOZn\src\vector_of_array.jl:315

Expected behavior

Returning an empty array of results.

Minimal Reproducible Example 👇

using ModelingToolkit, ModelingToolkitStandardLibrary, ModelingToolkitStandardLibrary.Mechanical.TranslationalPosition, OrdinaryDiffEq
sol = solve(ODEProblem(structural_simplify(Mass(m=1.0,name=:m)), [], (0.0, 1.0)), Tsit5())
# error 1
sol(ts, idxs=SymbolicUtils.BasicSymbolic{Real}[])
# error 2
sol([0.5], idxs=[])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants