From 1b28561c1373c6c322c6d488d134cabd1810576e Mon Sep 17 00:00:00 2001 From: Sathvik Bhagavan Date: Sun, 6 Aug 2023 14:36:18 +0000 Subject: [PATCH] refactor: use tuple for `p` instead of array --- src/FMI2/sim.jl | 8 ++++---- src/FMI3/sim.jl | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/FMI2/sim.jl b/src/FMI2/sim.jl index 49495692..ac18f6ef 100644 --- a/src/FMI2/sim.jl +++ b/src/FMI2/sim.jl @@ -231,7 +231,7 @@ end function fx(c::FMU2Component, dx::AbstractArray{<:Real}, x::AbstractArray{<:Real}, - p::AbstractArray, + p::Tuple, t::Real) c.solution.evals_fx_inplace += 1 @@ -247,7 +247,7 @@ end function fx(c::FMU2Component, x::AbstractArray{<:Real}, - p::AbstractArray, + p::Tuple, t::Real) c.solution.evals_fx_outofplace += 1 @@ -269,9 +269,9 @@ function fmi2SimulateME(c::FMU2Component, tspan::Union{Tuple{Float64, Float64}, end # sets up the ODEProblem for simulating a ME-FMU -function setupODEProblem(c::FMU2Component, x0::AbstractArray{fmi2Real}, tspan::Union{Tuple{Float64, Float64}, Nothing}=nothing; p=[], customFx=nothing) +function setupODEProblem(c::FMU2Component, x0::AbstractArray{fmi2Real}, tspan::Union{Tuple{Float64, Float64}, Nothing}=nothing; p=(), customFx=nothing) - p = [] + p = () if c.fmu.executionConfig.inPlace if customFx === nothing diff --git a/src/FMI3/sim.jl b/src/FMI3/sim.jl index 2eeb2301..aa3932fb 100644 --- a/src/FMI3/sim.jl +++ b/src/FMI3/sim.jl @@ -230,7 +230,7 @@ end function fx(c::FMU3Instance, dx::AbstractArray{<:Real}, x::AbstractArray{<:Real}, - p::AbstractArray, + p::Tuple, t::Real) # if isa(t, ForwardDiff.Dual) @@ -799,12 +799,12 @@ function fmi3SimulateME(c::FMU3Instance, t_start::Union{Real, Nothing} = nothing end # sets up the ODEProblem for simulating a ME-FMU -function setupODEProblem(c::FMU3Instance, x0::AbstractArray{fmi3Float64}, t_start::fmi3Float64, t_stop::fmi3Float64; p=[], customFx=nothing) +function setupODEProblem(c::FMU3Instance, x0::AbstractArray{fmi3Float64}, t_start::fmi3Float64, t_stop::fmi3Float64; p=(), customFx=nothing) if customFx === nothing customFx = (dx, x, p, t) -> fx(c, dx, x, p, t) end - p = [] + p = () c.problem = ODEProblem(customFx, x0, (t_start, t_stop), p,) return c.problem