Skip to content

Commit

Permalink
fix: default to ContinuousTimeseries for symbol not in SymbolCache
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Jul 5, 2024
1 parent 6406219 commit 11b073e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/symbol_cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ function timeseries_parameter_index(sc::SymbolCache, sym)
return get(sc.timeseries_parameters, sym, nothing)
end
end

for symT in [Any, Expr, AbstractArray]
@eval function get_all_timeseries_indexes(
::SymbolCache{Nothing, Nothing, Nothing}, ::$symT)
Set([ContinuousTimeseries()])
end
end

function get_all_timeseries_indexes(sc::SymbolCache, sym)
if is_variable(sc, sym) || is_independent_variable(sc, sym)
return Set([ContinuousTimeseries()])
Expand Down
5 changes: 5 additions & 0 deletions test/symbol_cache_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,8 @@ sc2 = copy(sc)
@test sc.variables == sc2.variables
@test sc.parameters == sc2.parameters
@test sc.independent_variables == sc2.independent_variables

sc = SymbolCache()
for sym in [1, :a, :(a + b), "foo", [:a, :b], [:(a + b), :c]]
@test only(get_all_timeseries_indexes(sc, sym)) == ContinuousTimeseries()
end

0 comments on commit 11b073e

Please sign in to comment.