Skip to content

Commit

Permalink
fix: do not call current_time for time-independent systems
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Feb 26, 2024
1 parent 8ebdf3f commit 780d7a1
Showing 1 changed file with 38 additions and 28 deletions.
66 changes: 38 additions & 28 deletions src/state_indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -216,39 +216,49 @@ for (t1, t2) in [
end
else
obs = observed(sys, sym isa Tuple ? collect(sym) : sym)
return let obs = obs, is_tuple = sym isa Tuple
function _getter2(::NotTimeseries, prob)
obs(state_values(prob), parameter_values(prob), current_time(prob))
_getter2 = if is_time_dependent(sys)
let obs = obs, is_tuple = sym isa Tuple
function _getter2a(::NotTimeseries, prob)
obs(state_values(prob), parameter_values(prob), current_time(prob))

Check warning on line 222 in src/state_indexing.jl

View check run for this annotation

Codecov / codecov/patch

src/state_indexing.jl#L219-L222

Added lines #L219 - L222 were not covered by tests
end
function _getter2a(::Timeseries, prob)
obs.(state_values(prob), (parameter_values(prob),),

Check warning on line 225 in src/state_indexing.jl

View check run for this annotation

Codecov / codecov/patch

src/state_indexing.jl#L224-L225

Added lines #L224 - L225 were not covered by tests
current_time(prob))
end
function _getter2a(::Timeseries, prob, i)
obs(state_values(prob, i),

Check warning on line 229 in src/state_indexing.jl

View check run for this annotation

Codecov / codecov/patch

src/state_indexing.jl#L228-L229

Added lines #L228 - L229 were not covered by tests
parameter_values(prob),
current_time(prob, i))
end
_getter2a

Check warning on line 233 in src/state_indexing.jl

View check run for this annotation

Codecov / codecov/patch

src/state_indexing.jl#L233

Added line #L233 was not covered by tests
end
function _getter2(::Timeseries, prob)
obs.(state_values(prob), (parameter_values(prob),), current_time(prob))
else
let obs = obs, is_tuple = sym isa Tuple
function _getter2b(::NotTimeseries, prob)
obs(state_values(prob), parameter_values(prob))

Check warning on line 238 in src/state_indexing.jl

View check run for this annotation

Codecov / codecov/patch

src/state_indexing.jl#L236-L238

Added lines #L236 - L238 were not covered by tests
end
_getter2b

Check warning on line 240 in src/state_indexing.jl

View check run for this annotation

Codecov / codecov/patch

src/state_indexing.jl#L240

Added line #L240 was not covered by tests
end
function _getter2(::Timeseries, prob, i)
obs(state_values(prob, i),
parameter_values(prob),
current_time(prob, i))
end
return if sym isa Tuple
let _getter2 = _getter2
function getter2(prob)
Tuple(_getter2(is_timeseries(prob), prob))

Check warning on line 246 in src/state_indexing.jl

View check run for this annotation

Codecov / codecov/patch

src/state_indexing.jl#L243-L246

Added lines #L243 - L246 were not covered by tests
end
function getter2(prob, i)
Tuple(_getter2(is_timeseries(prob), prob, i))

Check warning on line 249 in src/state_indexing.jl

View check run for this annotation

Codecov / codecov/patch

src/state_indexing.jl#L248-L249

Added lines #L248 - L249 were not covered by tests
end
getter2

Check warning on line 251 in src/state_indexing.jl

View check run for this annotation

Codecov / codecov/patch

src/state_indexing.jl#L251

Added line #L251 was not covered by tests
end

if is_tuple
let _getter2 = _getter2
function getter2(prob)
Tuple(_getter2(is_timeseries(prob), prob))
end
function getter2(prob, i)
Tuple(_getter2(is_timeseries(prob), prob, i))
end
getter2
else
let _getter2 = _getter2
function getter3(prob)
_getter2(is_timeseries(prob), prob)

Check warning on line 256 in src/state_indexing.jl

View check run for this annotation

Codecov / codecov/patch

src/state_indexing.jl#L254-L256

Added lines #L254 - L256 were not covered by tests
end
else
let _getter2 = _getter2
function getter3(prob)
_getter2(is_timeseries(prob), prob)
end
function getter3(prob, i)
_getter2(is_timeseries(prob), prob, i)
end
getter3
function getter3(prob, i)
_getter2(is_timeseries(prob), prob, i)

Check warning on line 259 in src/state_indexing.jl

View check run for this annotation

Codecov / codecov/patch

src/state_indexing.jl#L258-L259

Added lines #L258 - L259 were not covered by tests
end
getter3

Check warning on line 261 in src/state_indexing.jl

View check run for this annotation

Codecov / codecov/patch

src/state_indexing.jl#L261

Added line #L261 was not covered by tests
end
end
end
Expand Down

0 comments on commit 780d7a1

Please sign in to comment.