File tree Expand file tree Collapse file tree 1 file changed +22
-12
lines changed Expand file tree Collapse file tree 1 file changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -713,6 +713,26 @@ function maybe_build_initialization_problem(
713
713
initializeprobpmap))
714
714
end
715
715
716
+ """
717
+ $(TYPEDSIGNATURES)
718
+
719
+ Calculate the floating point type to use from the given `varmap` by looking at variables
720
+ with a constant value.
721
+ """
722
+ function float_type_from_varmap (varmap, floatT = Bool)
723
+ for (k, v) in varmap
724
+ symbolic_type (v) == NotSymbolic () || continue
725
+ is_array_of_symbolics (v) && continue
726
+
727
+ if v isa AbstractArray
728
+ floatT = promote_type (floatT, eltype (v))
729
+ elseif v isa Real
730
+ floatT = promote_type (floatT, typeof (v))
731
+ end
732
+ end
733
+ return float (floatT)
734
+ end
735
+
716
736
"""
717
737
$(TYPEDSIGNATURES)
718
738
@@ -818,20 +838,10 @@ function process_SciMLProblem(
818
838
819
839
floatT = Bool
820
840
if u0Type <: AbstractArray && eltype (u0Type) <: Real
821
- floatT = eltype (u0Type)
841
+ floatT = float ( eltype (u0Type) )
822
842
else
823
- for (k, v) in op
824
- symbolic_type (v) == NotSymbolic () || continue
825
- is_array_of_symbolics (v) && continue
826
-
827
- if v isa AbstractArray
828
- floatT = promote_type (floatT, eltype (v))
829
- elseif v isa Real
830
- floatT = promote_type (floatT, typeof (v))
831
- end
832
- end
843
+ floatT = float_type_from_varmap (op, floatT)
833
844
end
834
- floatT = float (floatT)
835
845
836
846
if ! is_time_dependent (sys) || is_initializesystem (sys)
837
847
add_observed_equations! (u0map, obs)
You can’t perform that action at this time.
0 commit comments