Fix symbol indexing by checking that observed !== nothing#241
Merged
Conversation
Contributor
Author
|
Sorry about the big diff. I have my editor auto-format files on save. Base.@propagate_inbounds function Base.getindex(A::AbstractDiffEqArray{T, N},
sym) where {T, N}
if issymbollike(sym) && !isnothing(A.sc)
if is_indep_sym(A.sc, sym)
return A.t
elseif is_state_sym(A.sc, sym)
return getindex.(A.u, state_sym_to_index(A.sc, sym))
elseif is_param_sym(A.sc, sym)
return A.p[param_sym_to_index(A.sc, sym)]
elseif A.observed !== nothing
return observed(A, sym, :)
end
elseif all(issymbollike, sym) && !isnothing(A.sc)
if all(Base.Fix1(is_param_sym, A.sc), sym)
return getindex.((A,), sym)
else
return [getindex.((A,), sym, i) for i in eachindex(A.t)]
end
end
return getindex.(A.u, sym)
end
Base.@propagate_inbounds function Base.getindex(A::AbstractDiffEqArray{T, N}, sym,
args...) where {T, N}
Main._a[] = (A, sym, args)
if issymbollike(sym) && !isnothing(A.sc)
if is_indep_sym(A.sc, sym)
return A.t[args...]
elseif is_state_sym(A.sc, sym)
return A[sym][args...]
elseif A.observed !== nothing
return observed(A, sym, args...)
end
elseif all(issymbollike, sym) && !isnothing(A.sc)
return reduce(vcat, map(s -> A[s, args...]', sym))
end
return getindex.(A.u, sym)
endI could instead place such a check inside the |
Add LabelledArrays to test deps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #240