@@ -27,6 +27,7 @@ following `getindex` methods:
27
27
third the index of the parameter in an element of the timeseries.
28
28
29
29
The three-argument version of [`parameter_values`](@ref) is implemented for this type.
30
+ The single-argument version of `parameter_values` returns the cached parameter object.
30
31
[`parameter_timeseries`](@ref) is implemented for this type. This type does not implement
31
32
any traits.
32
33
"""
@@ -56,12 +57,29 @@ Base.parent(ptc::ParameterTimeseriesCollection) = ptc.collection
56
57
Base. getindex (ptc:: ParameterTimeseriesCollection , idx) = ptc. collection[idx]
57
58
function Base. getindex (ptc:: ParameterTimeseriesCollection , idx:: ParameterTimeseriesIndex )
58
59
timeseries = ptc. collection[idx. timeseries_idx]
59
- return getu (timeseries, idx. parameter_idx)(timeseries)
60
+ return getindex .(state_values (timeseries), (idx. parameter_idx,))
61
+ end
62
+ function Base. getindex (
63
+ ptc:: ParameterTimeseriesCollection , idx:: ParameterTimeseriesIndex , subidx:: Union {
64
+ Int, CartesianIndex})
65
+ timeseries = ptc. collection[idx. timeseries_idx]
66
+ return state_values (timeseries, subidx)[idx. parameter_idx]
67
+ end
68
+ function Base. getindex (
69
+ ptc:: ParameterTimeseriesCollection , idx:: ParameterTimeseriesIndex , :: Colon )
70
+ return ptc[idx]
71
+ end
72
+ function Base. getindex (
73
+ ptc:: ParameterTimeseriesCollection , idx:: ParameterTimeseriesIndex , subidx:: AbstractArray{Bool} )
74
+ timeseries = ptc. collection[idx. timeseries_idx]
75
+ map (only (to_indices (current_time (timeseries), (subidx,)))) do i
76
+ state_values (timeseries, i)[idx. parameter_idx]
77
+ end
60
78
end
61
79
function Base. getindex (
62
80
ptc:: ParameterTimeseriesCollection , idx:: ParameterTimeseriesIndex , subidx)
63
81
timeseries = ptc. collection[idx. timeseries_idx]
64
- return getu (timeseries, idx . parameter_idx)( timeseries, subidx)
82
+ getindex .( state_values .(( timeseries,), subidx), idx . parameter_idx )
65
83
end
66
84
function Base. getindex (ptc:: ParameterTimeseriesCollection , ts_idx, subidx)
67
85
return state_values (ptc. collection[ts_idx], subidx)
@@ -70,6 +88,10 @@ function Base.getindex(ptc::ParameterTimeseriesCollection, ts_idx, subidx, param
70
88
return ptc[ParameterTimeseriesIndex (ts_idx, param_idx), subidx]
71
89
end
72
90
91
+ function parameter_values (ptc:: ParameterTimeseriesCollection )
92
+ return ptc. paramcache
93
+ end
94
+
73
95
function parameter_values (
74
96
ptc:: ParameterTimeseriesCollection , idx:: ParameterTimeseriesIndex , subidx)
75
97
return ptc[idx, subidx]
0 commit comments