diff --git a/src/SymbolicIndexingInterface.jl b/src/SymbolicIndexingInterface.jl index 34d57fd..a18e080 100644 --- a/src/SymbolicIndexingInterface.jl +++ b/src/SymbolicIndexingInterface.jl @@ -15,7 +15,8 @@ include("interface.jl") export SymbolCache include("symbol_cache.jl") -export parameter_values, set_parameter!, parameter_values_at_time, parameter_values_at_state_time, parameter_timeseries, getp, setp +export parameter_values, set_parameter!, parameter_values_at_time, + parameter_values_at_state_time, parameter_timeseries, getp, setp include("parameter_indexing.jl") export state_values, set_state!, current_time, getu, setu diff --git a/src/parameter_indexing.jl b/src/parameter_indexing.jl index 7dc160c..3161781 100644 --- a/src/parameter_indexing.jl +++ b/src/parameter_indexing.jl @@ -113,10 +113,16 @@ function _getp(sys, ::NotSymbolic, ::NotSymbolic, p) parameter_values(prob, p) end function _getter(::Timeseries, prob, i::Union{Int, CartesianIndex}) - parameter_values(parameter_values_at_time(prob, only(to_indices(parameter_timeseries(prob), (i,)))), p) + parameter_values( + parameter_values_at_time( + prob, only(to_indices(parameter_timeseries(prob), (i,)))), + p) end function _getter(::Timeseries, prob, i::Union{AbstractArray{Bool}, Colon}) - parameter_values.(parameter_values_at_time.((prob,), (j for j in only(to_indices(parameter_timeseries(prob), (i,))))), p) + parameter_values.( + parameter_values_at_time.((prob,), + (j for j in only(to_indices(parameter_timeseries(prob), (i,))))), + p) end function _getter(::Timeseries, prob, i) parameter_values.(parameter_values_at_time.((prob,), i), (p,)) @@ -132,7 +138,8 @@ end function _getp(sys, ::ScalarSymbolic, ::SymbolicTypeTrait, p) idx = parameter_index(sys, p) - return invoke(_getp, Tuple{Any, NotSymbolic, NotSymbolic, Any}, sys, NotSymbolic(), NotSymbolic(), idx) + return invoke(_getp, Tuple{Any, NotSymbolic, NotSymbolic, Any}, + sys, NotSymbolic(), NotSymbolic(), idx) return _getp(sys, NotSymbolic(), NotSymbolic(), idx) end @@ -155,7 +162,8 @@ for (t1, t2) in [ map(g -> g(prob, i), getters) end function _getter(::Timeseries, prob, i) - [map(g -> g(prob, j), getters) for j in only(to_indices(parameter_timeseries(prob), (i,)))] + [map(g -> g(prob, j), getters) + for j in only(to_indices(parameter_timeseries(prob), (i,)))] end function _getter!(buffer, ::NotTimeseries, prob) for (g, bufi) in zip(getters, eachindex(buffer)) @@ -176,7 +184,8 @@ for (t1, t2) in [ buffer end function _getter!(buffer, ::Timeseries, prob, i) - for (bufi, tsi) in zip(eachindex(buffer), only(to_indices(parameter_timeseries(prob), (i,)))) + for (bufi, tsi) in zip( + eachindex(buffer), only(to_indices(parameter_timeseries(prob), (i,)))) for (g, bufj) in zip(getters, eachindex(buffer[bufi])) buffer[bufi][bufj] = g(prob, tsi) end diff --git a/src/state_indexing.jl b/src/state_indexing.jl index 54eef94..7f884e6 100644 --- a/src/state_indexing.jl +++ b/src/state_indexing.jl @@ -185,7 +185,9 @@ for (t1, t2) in [ end function _getter2a(::Timeseries, prob) curtime = current_time(prob) - obs.(state_values(prob), (parameter_values_at_state_time(prob, i) for i in eachindex(curtime)), + obs.(state_values(prob), + (parameter_values_at_state_time(prob, i) + for i in eachindex(curtime)), curtime) end function _getter2a(::Timeseries, prob, i) diff --git a/src/trait.jl b/src/trait.jl index fbd0f9d..29c6673 100644 --- a/src/trait.jl +++ b/src/trait.jl @@ -101,4 +101,3 @@ function is_timeseries end is_timeseries(x) = is_timeseries(typeof(x)) is_timeseries(::Type) = NotTimeseries() - diff --git a/test/parameter_indexing_test.jl b/test/parameter_indexing_test.jl index f785ac0..655eef2 100644 --- a/test/parameter_indexing_test.jl +++ b/test/parameter_indexing_test.jl @@ -108,7 +108,7 @@ fs = FakeSolution( [i * ones(3) for i in 1:5], [0.2i for i in 1:5], [2i * ones(3) for i in 1:10], - [0.1i for i in 1:10], + [0.1i for i in 1:10] ) ps = fs.p p = fs.p[end] @@ -122,11 +122,13 @@ for (sym, val, arrval, check_inference) in [ ([:a, :b], p[1:2], vcat.(avals, bvals), true), (1:2, p[1:2], vcat.(avals, bvals), true), ((1, 2), Tuple(p[1:2]), tuple.(avals, bvals), true), - ([:a, [:b, :c]], [p[1], p[2:3]], [[i, [j, k]] for (i, j, k) in zip(avals, bvals, cvals)], false), + ([:a, [:b, :c]], [p[1], p[2:3]], + [[i, [j, k]] for (i, j, k) in zip(avals, bvals, cvals)], false), ([:a, (:b, :c)], [p[1], (p[2], p[3])], vcat.(avals, tuple.(bvals, cvals)), false), ((:a, [:b, :c]), (p[1], p[2:3]), tuple.(avals, vcat.(bvals, cvals)), true), ((:a, (:b, :c)), (p[1], (p[2], p[3])), tuple.(avals, tuple.(bvals, cvals)), true), - ([1, [:b, :c]], [p[1], p[2:3]], [[i, [j, k]] for (i, j, k) in zip(avals, bvals, cvals)], false), + ([1, [:b, :c]], [p[1], p[2:3]], + [[i, [j, k]] for (i, j, k) in zip(avals, bvals, cvals)], false), ([1, (:b, :c)], [p[1], (p[2], p[3])], vcat.(avals, tuple.(bvals, cvals)), false), ((1, [:b, :c]), (p[1], p[2:3]), tuple.(avals, vcat.(bvals, cvals)), true), ((1, (:b, :c)), (p[1], (p[2], p[3])), tuple.(avals, tuple.(bvals, cvals)), true) @@ -138,7 +140,8 @@ for (sym, val, arrval, check_inference) in [ @test get(fs) == fs.ps[sym] @test get(fs) == val - for sub_inds in [:, 3:5, rand(Bool, length(ps)), rand(eachindex(ps)), rand(CartesianIndices(ps))] + for sub_inds in [ + :, 3:5, rand(Bool, length(ps)), rand(eachindex(ps)), rand(CartesianIndices(ps))] if check_inference @inferred get(fs, sub_inds) end