Skip to content

Commit f918d83

Browse files
Default is_*_sym to false, update docstrings
- `is_indep_sym`, `is_state_sym` and `is_param_sym` default to false for types that don't implement a more specific method
1 parent c2ddad1 commit f918d83

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/interface.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ function independent_variables end
88
"""
99
$(TYPEDSIGNATURES)
1010
11-
Check if the given sym is an independent variable in the given system.
11+
Check if the given sym is an independent variable in the given system. Defaults
12+
to `false` if not implemented for the given system/container type.
1213
"""
1314
function is_indep_sym end
1415

@@ -29,7 +30,8 @@ function state_sym_to_index end
2930
"""
3031
$(TYPEDSIGNATURES)
3132
32-
Check if the given sym is a state variable in the given system.
33+
Check if the given sym is a state variable in the given system. Defaults
34+
to `false` if not implemented for the given system/container type.
3335
"""
3436
function is_state_sym end
3537

@@ -50,6 +52,7 @@ function param_sym_to_index end
5052
"""
5153
$(TYPEDSIGNATURES)
5254
53-
Check if the given sym is a parameter variable in the given system.
55+
Check if the given sym is a parameter variable in the given system. Defaults
56+
to `false` if not implemented for the given system/container type.
5457
"""
5558
function is_param_sym end

src/symbolcache.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@ end
77

88
independent_variables(sc::SymbolCache) = sc.indepsym
99
independent_variables(::SymbolCache{S,Nothing}) where {S} = []
10+
is_indep_sum(::Any, _) = false
1011
is_indep_sym(sc::SymbolCache, sym) = any(isequal(sym), sc.indepsym)
1112
is_indep_sym(::SymbolCache{S,Nothing}, _) where {S} = false
1213
states(sc::SymbolCache) = sc.syms
1314
states(::SymbolCache{Nothing}) = []
1415
state_sym_to_index(sc::SymbolCache, sym) = findfirst(isequal(sym), sc.syms)
1516
state_sym_to_index(::SymbolCache{Nothing}, _) = nothing
17+
is_state_sym(::Any, _) = false
1618
is_state_sym(sc::SymbolCache, sym) = !isnothing(state_sym_to_index(sc, sym))
1719
parameters(sc::SymbolCache) = sc.paramsyms
1820
parameters(::SymbolCache{S,T,Nothing}) where {S,T} = []
1921
param_sym_to_index(sc::SymbolCache, sym) = findfirst(isequal(sym), sc.paramsyms)
2022
param_sym_to_index(::SymbolCache{S,T,Nothing}, _) where {S,T} = nothing
23+
is_param_sym(::Any, _) = false
2124
is_param_sym(sc::SymbolCache, sym) = !isnothing(param_sym_to_index(sc, sym))
2225

2326
Base.copy(VA::SymbolCache) = typeof(VA)(

0 commit comments

Comments
 (0)