Open ErikQQY opened 2 months ago
Same issue with DiffEqArray
indexing:
julia> a = [[1 2; 3 4], [4 5; 6 7], [7 8; 9 10]]
julia> vb = DiffEqArray(a, [0.1,0.2,0.3])
t: 3-element Vector{Float64}:
0.1
0.2
0.3
u: 3-element Vector{Matrix{Int64}}:
[1 2; 3 4]
[4 5; 6 7]
[7 8; 9 10]
julia> vb[:,end]
2×2 Matrix{Int64}:
4 5
6 7
Yes this should just error. It should just require 3 indices since it's equivalent to:
julia> rand(2,2,2)[:,end]
ERROR: BoundsError: attempt to access 2×2×2 Array{Float64, 3} at index [1:2, 2]
Stacktrace:
[1] throw_boundserror(A::Array{Float64, 3}, I::Tuple{Base.Slice{Base.OneTo{Int64}}, Int64})
@ Base ./abstractarray.jl:737
[2] checkbounds
@ ./abstractarray.jl:702 [inlined]
[3] _getindex
@ ./multidimensional.jl:888 [inlined]
[4] getindex(::Array{Float64, 3}, ::Function, ::Int64)
@ Base ./abstractarray.jl:1291
[5] top-level scope
@ REPL[14]:1
if you want the last element, vb.u[end]
is correct.
Describe the bug 🐞
Expected behavior
I thought this should be the same no matter whether we are using
va[:,end]
orva.u[end]
?Environment (please complete the following information):
using Pkg; Pkg.status()
versioninfo()