Skip to content

Commit c91a425

Browse files
committed
fixup
1 parent aca8330 commit c91a425

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/vector_of_array.jl

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ Base.@pure __parameterless_type(T) = Base.typename(T).wrapper
7070
x <: Union{Symbol, AllObserved} && return quote true end
7171
ss = ["Operation", "Variable", "Sym", "Num", "Term"]
7272
s = string(Symbol(__parameterless_type(x)))
73-
bool = any(x -> occursin(x, s), ss)
74-
quote
73+
bool = any(x -> occursin(x, s), ss)
74+
quote
7575
$bool
7676
end
7777
end
@@ -161,8 +161,12 @@ end
161161

162162
# Interface for the linear indexing. This is just a view of the underlying nested structure
163163
@inline Base.firstindex(VA::AbstractVectorOfArray) = firstindex(VA.u)
164-
@inline Base.lastindex(VA::AbstractVectorOfArray) = lastindex(VA.u)
165-
164+
function Base.lastindex(A::AbstractVectorOfArray, i=1)
165+
i == 1 && return length(A)
166+
len1 = lastindex(A[1], i-1)
167+
all(x->isequal(lastindex(x, i-1), len1), A) && return len1
168+
throw(ArgumentError("`end` is not defined for AbstractVectorOfArray types when the arrays have different sizes. Either enforce that the arrays are all similarly sized or directly define the index value.
169+
Note that a common reason for this error in the SciMLSolution context comes from adaptively sized models. Using arguments like `saveat` can enforce that an ensemble of solutions are all saved at the same time points and thus all have the same size. Similarly, if an ODE is solved with adaptivity in the size of the system (such as for adaptive grids) then this error can refer to the changing size of the ODE through the time series."))
166170
@inline Base.length(VA::AbstractVectorOfArray) = length(VA.u)
167171
@inline Base.eachindex(VA::AbstractVectorOfArray) = Base.OneTo(length(VA.u))
168172
@inline Base.IteratorSize(VA::AbstractVectorOfArray) = Base.HasLength()
@@ -544,12 +548,4 @@ end
544548
end
545549
unpack_args_voa(i, args::Tuple{Any}) = (unpack_voa(args[1], i),)
546550
unpack_args_voa(::Any, args::Tuple{}) = ()
547-
548-
function Base.lastindex(A::AbstractVectorOfArray, i=1)
549-
i == 1 && return length(A)
550-
len1 = lastindex(A[1], i-1)
551-
all(x->isequal(lastindex(x, i-1), len1), A) && return len1
552-
throw(ArgumentError("`end` is not defined for AbstractVectorOfArray types when the arrays have different sizes. Either enforce that the arrays are all similarly sized or directly define the index value.
553-
554-
Note that a common reason for this error in the SciMLSolution context comes from adaptively sized models. Using arguments like `saveat` can enforce that an ensemble of solutions are all saved at the same time points and thus all have the same size. Similarly, if an ODE is solved with adaptivity in the size of the system (such as for adaptive grids) then this error can refer to the changing size of the ODE through the time series."))
555551
end

0 commit comments

Comments
 (0)