@@ -465,46 +465,20 @@ function Base.getproperty(A::DEIntegrator, sym::Symbol)
465465 end
466466end
467467
468- Base. @propagate_inbounds function _getindex (A:: DEIntegrator ,
469- :: NotSymbolic ,
470- I:: Union {Int, AbstractArray{Int},
471- CartesianIndex, Colon, BitArray,
472- AbstractArray{Bool}}. .. )
473- A. u[I... ]
474- end
475-
476- Base. @propagate_inbounds function _getindex (A:: DEIntegrator , :: ScalarSymbolic , sym)
477- if is_variable (A, sym)
478- return A[variable_index (A, sym)]
479- elseif is_parameter (A, sym)
480- error (" Indexing with parameters is deprecated. Use `getp(sys, $sym )(integrator)` for parameter indexing" )
481- elseif is_independent_variable (A, sym)
482- return A. t
483- elseif is_observed (A, sym)
484- return SymbolicIndexingInterface. observed (A, sym)(A. u, A. p, A. t)
485- else
486- error (" Tried to index integrator with a Symbol that was not found in the system." )
468+ Base. @propagate_inbounds function Base. getindex (A:: DEIntegrator , sym)
469+ if is_parameter (A, sym)
470+ error (" Indexing with parameters is deprecated. Use `integrator.ps[$sym ]` for parameter indexing." )
487471 end
472+ return getu (A, sym)(A)
488473end
489474
490- Base. @propagate_inbounds function _getindex (A:: DEIntegrator , :: ArraySymbolic , sym)
491- return A[collect (sym)]
492- end
493-
494- Base. @propagate_inbounds function _getindex (
495- A:: DEIntegrator , :: ScalarSymbolic , sym:: Union{Tuple, AbstractArray} )
496- return getindex .((A,), sym)
497- end
498-
499- Base. @propagate_inbounds function Base. getindex (A:: DEIntegrator , sym)
500- symtype = symbolic_type (sym)
501- elsymtype = symbolic_type (eltype (sym))
502-
503- if symtype != NotSymbolic ()
504- return _getindex (A, symtype, sym)
505- else
506- return _getindex (A, elsymtype, sym)
475+ Base. @propagate_inbounds function Base. getindex (
476+ A:: DEIntegrator , sym:: Union{AbstractArray, Tuple} )
477+ if symbolic_type (sym) == NotSymbolic () && any (x -> is_parameter (A, x), sym) ||
478+ is_parameter (A, sym)
479+ error (" Indexing with parameters is deprecated. Use `integrator.ps[$sym ]` for parameter indexing." )
507480 end
481+ return getu (A, sym)(A)
508482end
509483
510484Base. @propagate_inbounds function Base. getindex (
@@ -522,25 +496,18 @@ function observed(A::DEIntegrator, sym)
522496end
523497
524498function Base. setindex! (A:: DEIntegrator , val, sym)
525- has_sys (A. f) ||
526- error (" Invalid indexing of integrator: Integrator does not support indexing without a system" )
527- if symbolic_type (sym) == ScalarSymbolic ()
528- if is_variable (A, sym)
529- set_state! (A, val, variable_index (A, sym))
530- elseif is_parameter (A, sym)
531- error (" Parameter indexing is deprecated. Use `setp(sys, $sym )(integrator, $val )` to set parameter value." )
532- else
533- error (" Invalid indexing of integrator: $sym is not a state or parameter, it may be an observed variable." )
534- end
535- return A
536- elseif symbolic_type (sym) == ArraySymbolic ()
537- setindex! .((A,), val, collect (sym))
538- return A
539- else
540- sym isa AbstractArray || error (" Invalid indexing of integrator" )
541- setindex! .((A,), val, sym)
542- return A
499+ if is_parameter (A, sym)
500+ error (" Indexing with parameters is deprecated. Use `integrator.ps[$sym ] = $val ` for parameter indexing." )
501+ end
502+ setu (A, sym)(A, val)
503+ end
504+
505+ function Base. setindex! (A:: DEIntegrator , val, sym:: Union{AbstractArray, Tuple} )
506+ if symbolic_type (sym) == NotSymbolic () && any (x -> is_parameter (A, x), sym) ||
507+ is_parameter (A, sym)
508+ error (" Indexing with parameters is deprecated. Use `integrator.ps[$sym ] = $val ` for parameter indexing." )
543509 end
510+ setu (A, sym)(A, val)
544511end
545512
546513# ## Integrator traits
0 commit comments