Skip to content

Commit f91d994

Browse files
refactor: remove time_varying_as_func
1 parent e4866d4 commit f91d994

File tree

4 files changed

+5
-30
lines changed

4 files changed

+5
-30
lines changed

src/inputoutput.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ function generate_control_function(sys::AbstractODESystem, inputs = unbound_inpu
218218
inputs = setdiff(inputs, disturbance_inputs)
219219
# ps = [ps; disturbance_inputs]
220220
end
221-
inputs = map(x -> time_varying_as_func(value(x), sys), inputs)
221+
inputs = map(value, inputs)
222222
disturbance_inputs = unwrap.(disturbance_inputs)
223223

224224
eqs = [eq for eq in full_equations(sys)]

src/systems/abstractsystem.jl

-14
Original file line numberDiff line numberDiff line change
@@ -1768,20 +1768,6 @@ function isaffine(sys::AbstractSystem)
17681768
all(isaffine(r, unknowns(sys)) for r in rhs)
17691769
end
17701770

1771-
function time_varying_as_func(x, sys::AbstractTimeDependentSystem)
1772-
# if something is not x(t) (the current unknown)
1773-
# but is `x(t-1)` or something like that, pass in `x` as a callable function rather
1774-
# than pass in a value in place of x(t).
1775-
#
1776-
# This is done by just making `x` the argument of the function.
1777-
if iscall(x) &&
1778-
issym(operation(x)) &&
1779-
!(length(arguments(x)) == 1 && isequal(arguments(x)[1], get_iv(sys)))
1780-
return operation(x)
1781-
end
1782-
return x
1783-
end
1784-
17851771
"""
17861772
$(SIGNATURES)
17871773

src/systems/callbacks.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,8 @@ Notes
598598
"""
599599
function compile_condition(cb::SymbolicDiscreteCallback, sys, dvs, ps;
600600
expression = Val{true}, eval_expression = false, eval_module = @__MODULE__, kwargs...)
601-
u = map(x -> time_varying_as_func(value(x), sys), dvs)
602-
p = map.(x -> time_varying_as_func(value(x), sys), reorder_parameters(sys, ps))
601+
u = map(value, dvs)
602+
p = map.(value, reorder_parameters(sys, ps))
603603
t = get_iv(sys)
604604
condit = condition(cb)
605605
cs = collect_constants(condit)
@@ -685,8 +685,8 @@ function compile_affect(eqs::Vector{Equation}, cb, sys, dvs, ps; outputidxs = no
685685
_ps = ps
686686
ps = reorder_parameters(sys, ps)
687687
if checkvars
688-
u = map(x -> time_varying_as_func(value(x), sys), dvs)
689-
p = map.(x -> time_varying_as_func(value(x), sys), ps)
688+
u = map(value, dvs)
689+
p = map.(value, ps)
690690
else
691691
u = dvs
692692
p = ps

src/systems/codegen_utils.jl

-11
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,6 @@ function build_function_wrapper(sys::AbstractSystem, expr, args...; p_start = 2,
179179

180180
args = ntuple(Val(length(args))) do i
181181
arg = args[i]
182-
# for time-dependent systems, all arguments are passed through `time_varying_as_func`
183-
# TODO: This is legacy behavior and a candidate for removal in v10 since we have callable
184-
# parameters now.
185-
if is_time_dependent(sys)
186-
arg = if symbolic_type(arg) == NotSymbolic()
187-
arg isa AbstractArray ?
188-
map(x -> time_varying_as_func(unwrap(x), sys), arg) : arg
189-
else
190-
time_varying_as_func(unwrap(arg), sys)
191-
end
192-
end
193182
# Make sure to use the proper names for arguments
194183
if symbolic_type(arg) == NotSymbolic() && arg isa AbstractArray
195184
DestructuredArgs(arg, generated_argument_name(i); create_bindings)

0 commit comments

Comments
 (0)