Skip to content

Commit

Permalink
Merge pull request #89 from SciML/as/hotfix
Browse files Browse the repository at this point in the history
fix: default to ContinuousTimeseries for symbol not in `SymbolCache`
  • Loading branch information
AayushSabharwal authored Jul 5, 2024
2 parents 6406219 + 6500eb0 commit c834a31
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SymbolicIndexingInterface"
uuid = "2efcf032-c050-4f8e-a9bb-153293bab1f5"
authors = ["Aayush Sabharwal <[email protected]> and contributors"]
version = "0.3.25"
version = "0.3.26"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand Down
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 c834a31

Please sign in to comment.