@@ -5,6 +5,11 @@ Using `indp`, return an object that implements the index provider interface. In
55itself implements the interface, `indp` can be returned as-is. All index provider interface
66methods fall back to calling the same method on `symbolic_container(indp)`, so this may be
77used for trivial implementations of the interface that forward all calls to another object.
8+
9+ Note that this method is optional. Thus the correct method to check for a fallback is:
10+ ```julia
11+ hasmethod(symbolic_container, Tuple{typeof(indp)}) && symbolic_container(indp) != indp
12+ ```
813"""
914function symbolic_container end
1015
@@ -59,8 +64,9 @@ parameter_index(indp, sym) = parameter_index(symbolic_container(indp), sym)
5964Check whether the given `sym` is a timeseries parameter in `indp`.
6065"""
6166function is_timeseries_parameter (indp, sym)
62- if hasmethod (symbolic_container, Tuple{typeof (indp)})
63- is_timeseries_parameter (symbolic_container (indp), sym)
67+ if hasmethod (symbolic_container, Tuple{typeof (indp)}) &&
68+ (sc = symbolic_container (indp)) != indp
69+ is_timeseries_parameter (sc, sym)
6470 else
6571 return false
6672 end
@@ -91,7 +97,8 @@ parameter in `indp`. Defaults to returning `nothing`. Respects the
9197[`symbolic_container`](@ref) fallback for `indp` if present.
9298"""
9399function timeseries_parameter_index (indp, sym)
94- if hasmethod (symbolic_container, Tuple{typeof (indp)})
100+ if hasmethod (symbolic_container, Tuple{typeof (indp)}) &&
101+ (sc = symbolic_container (indp)) != indp
95102 timeseries_parameter_index (symbolic_container (indp), sym)
96103 else
97104 return nothing
@@ -111,7 +118,8 @@ By default, this function returns `nothing`, indicating that the index provider
111118support generating parameter observed functions.
112119"""
113120function parameter_observed (indp, sym)
114- if hasmethod (symbolic_container, Tuple{typeof (indp)})
121+ if hasmethod (symbolic_container, Tuple{typeof (indp)}) &&
122+ (sc = symbolic_container (indp)) != indp
115123 return parameter_observed (symbolic_container (indp), sym)
116124 else
117125 return nothing
@@ -143,7 +151,8 @@ variable.
143151By default, this function returns `Set([ContinuousTimeseries()])`.
144152"""
145153function get_all_timeseries_indexes (indp, sym)
146- if hasmethod (symbolic_container, Tuple{typeof (indp)})
154+ if hasmethod (symbolic_container, Tuple{typeof (indp)}) &&
155+ (sc = symbolic_container (indp)) != indp
147156 return get_all_timeseries_indexes (symbolic_container (indp), sym)
148157 else
149158 return Set ([ContinuousTimeseries ()])
@@ -240,7 +249,8 @@ Return a dictionary mapping symbols in the index provider to their default value
240249This includes parameter symbols. The dictionary must be mutable.
241250"""
242251function default_values (indp)
243- if hasmethod (symbolic_container, Tuple{typeof (indp)})
252+ if hasmethod (symbolic_container, Tuple{typeof (indp)}) &&
253+ (sc = symbolic_container (indp)) != indp
244254 default_values (symbolic_container (indp))
245255 else
246256 Dict ()
0 commit comments