@@ -598,24 +598,42 @@ function SciMLBase.remake_initialization_data(
598
598
return SciMLBase. remake_initialization_data (sys, odefn, newu0, t0, newp, newu0, newp)
599
599
end
600
600
601
- function promote_u0_p (u0, p:: MTKParameters , t0)
602
- u0 = DiffEqBase. promote_u0 (u0, p. tunable, t0)
603
- u0 = DiffEqBase. promote_u0 (u0, p. initials, t0)
601
+ promote_type_with_nothing (:: Type{T} , :: Nothing ) where {T} = T
602
+ promote_type_with_nothing (:: Type{T} , :: SizedVector{0} ) where {T} = T
603
+ function promote_type_with_nothing (:: Type{T} , :: AbstractArray{T2} ) where {T, T2}
604
+ promote_type (T, T2)
605
+ end
604
606
605
- if ! isempty (p. tunable)
606
- tunables = DiffEqBase. promote_u0 (p. tunable, u0, t0)
607
- p = SciMLStructures. replace (SciMLStructures. Tunable (), p, tunables)
608
- end
609
- if ! isempty (p. initials)
610
- initials = DiffEqBase. promote_u0 (p. initials, u0, t0)
611
- p = SciMLStructures. replace (SciMLStructures. Initials (), p, initials)
607
+ promote_with_nothing (:: Type , :: Nothing ) = nothing
608
+ promote_with_nothing (:: Type , x:: SizedVector{0} ) = x
609
+ promote_with_nothing (:: Type{T} , x:: AbstractArray{T} ) where {T} = x
610
+ function promote_with_nothing (:: Type{T} , x:: AbstractArray{T2} ) where {T, T2}
611
+ if ArrayInterface. ismutable (x)
612
+ y = similar (x, T)
613
+ copyto! (y, x)
614
+ return y
615
+ else
616
+ yT = similar_type (x, T)
617
+ return yT (x)
612
618
end
613
-
614
- return u0, p
619
+ end
620
+ function promote_with_nothing (:: Type{T} , p:: MTKParameters ) where {T}
621
+ tunables = promote_with_nothing (T, p. tunable)
622
+ p = SciMLStructures. replace (SciMLStructures. Tunable (), p, tunables)
623
+ initials = promote_with_nothing (T, p. initials)
624
+ p = SciMLStructures. replace (SciMLStructures. Initials (), p, initials)
625
+ return p
615
626
end
616
627
617
628
function promote_u0_p (u0, p, t0)
618
- return DiffEqBase. promote_u0 (u0, p, t0), DiffEqBase. promote_u0 (p, u0, t0)
629
+ T = Union{}
630
+ T = promote_type_with_nothing (T, u0)
631
+ T = promote_type_with_nothing (T, p. tunable)
632
+ T = promote_type_with_nothing (T, p. initials)
633
+
634
+ u0 = promote_with_nothing (T, u0)
635
+ p = promote_with_nothing (T, p)
636
+ return u0, p
619
637
end
620
638
621
639
function SciMLBase. late_binding_update_u0_p (
0 commit comments