diff --git a/src/inputoutput.jl b/src/inputoutput.jl index 5f9420ff3a..28b60b13dc 100644 --- a/src/inputoutput.jl +++ b/src/inputoutput.jl @@ -218,7 +218,7 @@ function generate_control_function(sys::AbstractODESystem, inputs = unbound_inpu inputs = setdiff(inputs, disturbance_inputs) # ps = [ps; disturbance_inputs] end - inputs = map(x -> time_varying_as_func(value(x), sys), inputs) + inputs = map(value, inputs) disturbance_inputs = unwrap.(disturbance_inputs) eqs = [eq for eq in full_equations(sys)] diff --git a/src/systems/abstractsystem.jl b/src/systems/abstractsystem.jl index 67bcbc88c0..35ea90d6b7 100644 --- a/src/systems/abstractsystem.jl +++ b/src/systems/abstractsystem.jl @@ -1822,20 +1822,6 @@ function isaffine(sys::AbstractSystem) all(isaffine(r, unknowns(sys)) for r in rhs) end -function time_varying_as_func(x, sys::AbstractTimeDependentSystem) - # if something is not x(t) (the current unknown) - # but is `x(t-1)` or something like that, pass in `x` as a callable function rather - # than pass in a value in place of x(t). - # - # This is done by just making `x` the argument of the function. - if iscall(x) && - issym(operation(x)) && - !(length(arguments(x)) == 1 && isequal(arguments(x)[1], get_iv(sys))) - return operation(x) - end - return x -end - """ $(SIGNATURES) diff --git a/src/systems/callbacks.jl b/src/systems/callbacks.jl index 07809bf611..7d542d9bd0 100644 --- a/src/systems/callbacks.jl +++ b/src/systems/callbacks.jl @@ -598,8 +598,8 @@ Notes """ function compile_condition(cb::SymbolicDiscreteCallback, sys, dvs, ps; expression = Val{true}, eval_expression = false, eval_module = @__MODULE__, kwargs...) - u = map(x -> time_varying_as_func(value(x), sys), dvs) - p = map.(x -> time_varying_as_func(value(x), sys), reorder_parameters(sys, ps)) + u = map(value, dvs) + p = map.(value, reorder_parameters(sys, ps)) t = get_iv(sys) condit = condition(cb) cs = collect_constants(condit) @@ -685,8 +685,8 @@ function compile_affect(eqs::Vector{Equation}, cb, sys, dvs, ps; outputidxs = no _ps = ps ps = reorder_parameters(sys, ps) if checkvars - u = map(x -> time_varying_as_func(value(x), sys), dvs) - p = map.(x -> time_varying_as_func(value(x), sys), ps) + u = map(value, dvs) + p = map.(value, ps) else u = dvs p = ps diff --git a/src/systems/codegen_utils.jl b/src/systems/codegen_utils.jl index a3fe53b95d..bedfdbcc37 100644 --- a/src/systems/codegen_utils.jl +++ b/src/systems/codegen_utils.jl @@ -179,17 +179,6 @@ function build_function_wrapper(sys::AbstractSystem, expr, args...; p_start = 2, args = ntuple(Val(length(args))) do i arg = args[i] - # for time-dependent systems, all arguments are passed through `time_varying_as_func` - # TODO: This is legacy behavior and a candidate for removal in v10 since we have callable - # parameters now. - if is_time_dependent(sys) - arg = if symbolic_type(arg) == NotSymbolic() - arg isa AbstractArray ? - map(x -> time_varying_as_func(unwrap(x), sys), arg) : arg - else - time_varying_as_func(unwrap(arg), sys) - end - end # Make sure to use the proper names for arguments if symbolic_type(arg) == NotSymbolic() && arg isa AbstractArray DestructuredArgs(arg, generated_argument_name(i); create_bindings) diff --git a/test/odesystem.jl b/test/odesystem.jl index a45ed99f35..5710b50ed6 100644 --- a/test/odesystem.jl +++ b/test/odesystem.jl @@ -135,19 +135,7 @@ du = zeros(3) tgrad_iip(du, u, p, t) @test du == [0.0, -u[2], 0.0] -@parameters σ′(t - 1) -eqs = [D(x) ~ σ′ * (y - x), - D(y) ~ x * (ρ - z) - y, - D(z) ~ x * y - β * z * κ] -@named de = ODESystem(eqs, t) -test_diffeq_inference("global iv-varying", de, t, (x, y, z), (σ′, ρ, β)) - -f = generate_function(de, [x, y, z], [σ′, ρ, β], expression = Val{false})[2] -du = [0.0, 0.0, 0.0] -f(du, [1.0, 2.0, 3.0], [x -> x + 7, 2, 3], 5.0) -@test du ≈ [11, -3, -7] - -@parameters σ(..) +@parameters (σ::Function)(..) eqs = [D(x) ~ σ(t - 1) * (y - x), D(y) ~ x * (ρ - z) - y, D(z) ~ x * y - β * z * κ]