Skip to content

Commit 39c3708

Browse files
Route A[sym, :] through A[sym] for symbolic indices
`sol[arr_sym, :]` should be equivalent to `sol[arr_sym]` — both ask for the full timeseries of the symbolic indices. Currently the `:`-suffixed form errors with a broadcast shape mismatch inside SII's `GetStateIndex` when the underlying index resolves to a `Vector{Int}` (i.e. when the symbol is array-valued like `x(t)[1:3]`): DimensionMismatch: arrays could not be broadcast to a common size: a has axes Base.OneTo(N) and b has axes Base.OneTo(K) (SII's `(gsi::GetStateIndex)(::Timeseries, prob, i)` broadcasts `gsi.idx` against `state_values(prob, i)` without wrapping it in a 1-tuple, so a length-N timeseries broadcast against a length-K idx vector errors. A companion fix is being submitted upstream.) Short-circuiting `A[sym, :]` to `A[sym]` here both restores the intended semantics and avoids the broken SII codepath. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
1 parent 2c2e5ec commit 39c3708

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/vector_of_array.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,15 @@ Base.@propagate_inbounds function Base.getindex(A::AbstractVectorOfArray, _arg,
797797
end
798798
symtype = symbolic_type(_arg)
799799
elsymtype = symbolic_type(eltype(_arg))
800+
# For symbolic indices, `A[sym, :]` is semantically equivalent to `A[sym]`
801+
# (the no-args symbolic getindex already returns the full timeseries).
802+
# Routing through the no-args path here also avoids a broadcast shape bug
803+
# in SymbolicIndexingInterface's `GetStateIndex` when the underlying index
804+
# is a `Vector{Int}` (array-symbolic) combined with a `Colon` time index.
805+
if (symtype != NotSymbolic() || elsymtype != NotSymbolic()) &&
806+
length(args) == 1 && args[1] === Colon()
807+
return A[_arg]
808+
end
800809

801810
return if symtype == NotSymbolic() && elsymtype == NotSymbolic()
802811
if _arg isa Union{Tuple, AbstractArray} &&

0 commit comments

Comments
 (0)