Skip to content

Commit 9a8d1c0

Browse files
feat: add is_parameter_timeseries trait
1 parent da1f249 commit 9a8d1c0

File tree

4 files changed

+43
-20
lines changed

4 files changed

+43
-20
lines changed

docs/src/api.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ observed
3434

3535
## Value provider interface
3636

37+
### State indexing
38+
39+
```@docs
40+
Timeseries
41+
NotTimeseries
42+
is_timeseries
43+
state_values
44+
set_state!
45+
current_time
46+
getu
47+
setu
48+
```
49+
3750
### Parameter indexing
3851

3952
```@docs
@@ -52,25 +65,12 @@ simulation (such as by callbacks), it must implement the following methods to en
5265
correct functioning of [`getu`](@ref) and [`getp`](@ref).
5366

5467
```@docs
68+
is_parameter_timeseries
5569
parameter_timeseries
5670
parameter_values_at_time
5771
parameter_values_at_state_time
5872
```
5973

60-
61-
### State indexing
62-
63-
```@docs
64-
Timeseries
65-
NotTimeseries
66-
is_timeseries
67-
state_values
68-
set_state!
69-
current_time
70-
getu
71-
setu
72-
```
73-
7474
### Batched Queries and Updates
7575

7676
```@docs

docs/src/terminology.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ In code samples, a value provider is typically denoted with the name `valp`.
5656
providers. This allows for several syntactic improvements. The [`symbolic_container`](@ref)
5757
function is useful in defining such objects.
5858

59-
!!! note "Timeseries objects"
60-
The documentation uses "Timeseries objects" to refer to value providers which implement
61-
the [`Timeseries`](@ref) variant of the [`is_timeseries`](@ref) trait.
59+
### Timeseries objects
60+
61+
Timeseries objects are value providers which implement the [`Timeseries`](@ref) variant of
62+
the [`is_timeseries`](@ref) trait.
63+
64+
### Parameter timeseries objects
65+
66+
Parameter timeseries objects are timeseries objects which implement the
67+
[`Timeseries`](@ref) variant of the [`is_parameter_timeseries`](@ref) trait.

src/SymbolicIndexingInterface.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ using Accessors: @reset
88
RuntimeGeneratedFunctions.init(@__MODULE__)
99

1010
export ScalarSymbolic, ArraySymbolic, NotSymbolic, symbolic_type, hasname, getname,
11-
Timeseries, NotTimeseries, is_timeseries
11+
Timeseries, NotTimeseries, is_timeseries, is_parameter_timeseries
1212
include("trait.jl")
1313

1414
export is_variable, variable_index, variable_symbols, is_parameter, parameter_index,

src/trait.jl

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ data. It may still be time-dependent. For example, an `ODEProblem` only stores
129129
the initial state of a system, so it is `NotTimeseries`, but still time-dependent.
130130
This is the default trait variant for all types.
131131
132-
See also: [`Timeseries`](@ref), [`is_timeseries`](@ref)
132+
See also: [`Timeseries`](@ref), [`is_timeseries`](@ref).
133133
"""
134134
struct NotTimeseries <: IsTimeseriesTrait end
135135

@@ -138,10 +138,27 @@ struct NotTimeseries <: IsTimeseriesTrait end
138138
is_timeseries(::Type)
139139
140140
Get the timeseries trait of a type. Defaults to [`NotTimeseries`](@ref) for all types.
141+
A type for which `is_timeseries(T) == Timeseries()` may also have a parameter timeseries.
142+
This is determined by the [`is_parameter_timeseries`](@ref) trait.
141143
142-
See also: [`Timeseries`](@ref), [`NotTimeseries`](@ref)
144+
See also: [`Timeseries`](@ref), [`NotTimeseries`](@ref), [`is_parameter_timeseries`](@ref).
143145
"""
144146
function is_timeseries end
145147

146148
is_timeseries(x) = is_timeseries(typeof(x))
147149
is_timeseries(::Type) = NotTimeseries()
150+
151+
"""
152+
is_parameter_timeseries(x) = is_parameter_timeseries(typeof(x))
153+
is_parameter_timeseries(::Type)
154+
155+
Get the parameter timeseries trait of a type. Defaults to [`NotTimeseries`](@ref) for all
156+
types. A type for which `is_parameter_timeseries(T) == Timeseries()` must also have
157+
`is_timeseries(T) == Timeseries()`.
158+
159+
See also: [`Timeseries`](@ref), [`NotTimeseries`](@ref), [`is_timeseries`](@ref).
160+
"""
161+
function is_parameter_timeseries end
162+
163+
is_parameter_timeseries(x) = is_parameter_timeseries(typeof(x))
164+
is_parameter_timeseries(::Type) = NotTimeseries()

0 commit comments

Comments
 (0)