@@ -638,24 +638,44 @@ function SciMLBase.remake_initialization_data(
638638 return SciMLBase. remake_initialization_data (sys, odefn, newu0, t0, newp, newu0, newp)
639639end
640640
641- function promote_u0_p (u0, p:: MTKParameters , t0)
642- u0 = DiffEqBase. promote_u0 (u0, p. tunable, t0)
643- u0 = DiffEqBase. promote_u0 (u0, p. initials, t0)
641+ promote_type_with_nothing (:: Type{T} , :: Nothing ) where {T} = T
642+ promote_type_with_nothing (:: Type{T} , :: SizedVector{0} ) where {T} = T
643+ function promote_type_with_nothing (:: Type{T} , :: AbstractArray{T2} ) where {T, T2}
644+ promote_type (T, T2)
645+ end
646+ function promote_type_with_nothing (:: Type{T} , p:: MTKParameters ) where {T}
647+ promote_type_with_nothing (promote_type_with_nothing (T, p. tunable), p. initials)
648+ end
644649
645- if ! isempty (p. tunable)
646- tunables = DiffEqBase. promote_u0 (p. tunable, u0, t0)
647- p = SciMLStructures. replace (SciMLStructures. Tunable (), p, tunables)
648- end
649- if ! isempty (p. initials)
650- initials = DiffEqBase. promote_u0 (p. initials, u0, t0)
651- p = SciMLStructures. replace (SciMLStructures. Initials (), p, initials)
650+ promote_with_nothing (:: Type , :: Nothing ) = nothing
651+ promote_with_nothing (:: Type , x:: SizedVector{0} ) = x
652+ promote_with_nothing (:: Type{T} , x:: AbstractArray{T} ) where {T} = x
653+ function promote_with_nothing (:: Type{T} , x:: AbstractArray{T2} ) where {T, T2}
654+ if ArrayInterface. ismutable (x)
655+ y = similar (x, T)
656+ copyto! (y, x)
657+ return y
658+ else
659+ yT = similar_type (x, T)
660+ return yT (x)
652661 end
653-
654- return u0, p
662+ end
663+ function promote_with_nothing (:: Type{T} , p:: MTKParameters ) where {T}
664+ tunables = promote_with_nothing (T, p. tunable)
665+ p = SciMLStructures. replace (SciMLStructures. Tunable (), p, tunables)
666+ initials = promote_with_nothing (T, p. initials)
667+ p = SciMLStructures. replace (SciMLStructures. Initials (), p, initials)
668+ return p
655669end
656670
657671function promote_u0_p (u0, p, t0)
658- return DiffEqBase. promote_u0 (u0, p, t0), DiffEqBase. promote_u0 (p, u0, t0)
672+ T = Union{}
673+ T = promote_type_with_nothing (T, u0)
674+ T = promote_type_with_nothing (T, p)
675+
676+ u0 = promote_with_nothing (T, u0)
677+ p = promote_with_nothing (T, p)
678+ return u0, p
659679end
660680
661681function SciMLBase. late_binding_update_u0_p (
0 commit comments