diff --git a/src/Blocks/sources.jl b/src/Blocks/sources.jl index 538db6547..9b17e33d1 100644 --- a/src/Blocks/sources.jl +++ b/src/Blocks/sources.jl @@ -745,7 +745,7 @@ function cached_interpolation(interpolation_type, u, x, args) # to update the cache if needed (and setindex! is not defined on ranges) # with a view from MTKParameters, so we collect to get a vector prev_x = DiffCache(collect(x)) - interp = GeneralLazyBufferCache() do (u,x) + interp = GeneralLazyBufferCache() do (u, x) interpolation_type(get_tmp(prev_u, u), get_tmp(prev_x, x), args...) end @@ -758,16 +758,17 @@ function cached_interpolation(interpolation_type, u, x, args) if (u, x) ≠ (get_tmp(prev_u, u), get_tmp(prev_x, x)) get_tmp(prev_u, u) .= u get_tmp(prev_x, x) .= x - interp.bufs[(u,x)] = interpolation_type( + interp.bufs[(u, x)] = interpolation_type( get_tmp(prev_u, u), get_tmp(prev_x, x), args...) else - interp[(u,x)] + interp[(u, x)] end end end end -@register_symbolic interpolation_builder(f::Function, u::AbstractArray, x::AbstractArray, args::Tuple) +@register_symbolic interpolation_builder( + f::Function, u::AbstractArray, x::AbstractArray, args::Tuple) interpolation_builder(f, u, x, args) = f(u, x, args) """ @@ -790,7 +791,8 @@ such as `LinearInterpolation`, `ConstantInterpolation` or `CubicSpline`. # Connectors: - `output`: a [`RealOutput`](@ref) connector corresponding to the interpolated value """ -function ParametrizedInterpolation(interp_type::T, u::AbstractVector, x::AbstractVector, args...; name) where {T} +function ParametrizedInterpolation( + interp_type::T, u::AbstractVector, x::AbstractVector, args...; name) where {T} @parameters data[1:length(x)] = u @parameters ts[1:length(x)] = x @parameters interpolation_type::T=interp_type [tunable = false] interpolation_args::Tuple=args [tunable = false] @@ -803,9 +805,11 @@ function ParametrizedInterpolation(interp_type::T, u::AbstractVector, x::Abstrac eqs = [output.u ~ apply_interpolation(interpolator, t)] - ODESystem(eqs, t, [], [data, ts, interpolation_type, interpolation_args, interpolator, memoized_builder]; + ODESystem(eqs, t, [], + [data, ts, interpolation_type, interpolation_args, interpolator, memoized_builder]; parameter_dependencies = [ - interpolator => interpolation_builder(memoized_builder, data, ts, interpolation_args) + interpolator => interpolation_builder( + memoized_builder, data, ts, interpolation_args) ], systems = [output], name) diff --git a/src/Hydraulic/IsothermalCompressible/IsothermalCompressible.jl b/src/Hydraulic/IsothermalCompressible/IsothermalCompressible.jl index ce5e26907..3403ee022 100644 --- a/src/Hydraulic/IsothermalCompressible/IsothermalCompressible.jl +++ b/src/Hydraulic/IsothermalCompressible/IsothermalCompressible.jl @@ -1,5 +1,5 @@ """ -Library to model iso-thermal compressible liquid fluid flow +Library to model iso-thermal compressible liquid fluid flow """ module IsothermalCompressible diff --git a/test/Blocks/sources.jl b/test/Blocks/sources.jl index da378e083..af23dbff8 100644 --- a/test/Blocks/sources.jl +++ b/test/Blocks/sources.jl @@ -498,7 +498,7 @@ end @test SciMLBase.successful_retcode(sol) - prob2 = remake(prob, p=[i.data => ones(15)]) + prob2 = remake(prob, p = [i.data => ones(15)]) sol2 = solve(prob2) @test SciMLBase.successful_retcode(sol2) @@ -525,7 +525,8 @@ end set_data! = setp(prob, i.data) of = OptimizationFunction(loss, AutoForwardDiff()) - op = OptimizationProblem(of, u, (prob, set_data!), lb = zeros(15), ub = fill(2.0, 15)) + op = OptimizationProblem( + of, u, (prob, set_data!), lb = zeros(15), ub = fill(2.0, 15)) # check that type changing works @test length(ForwardDiff.gradient(x -> of(x, (prob, set_data!)), u)) == 15