Skip to content

Commit e62e3ee

Browse files
author
Brad Carman
committed
improvements to protmote_to_concrete
1 parent b4f821e commit e62e3ee

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/utils.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -670,23 +670,23 @@ function promote_to_concrete(vs; tofloat = true, use_union = true)
670670
E = float(E)
671671
end
672672
end
673+
if C === nothing
674+
C = E
675+
end
673676
if use_union
674-
if C === nothing
675-
C = E
676-
else
677-
C = Union{C, E}
678-
end
677+
C = Union{C, E}
679678
else
679+
@assert C == E "`promote_to_concrete` can't make type $E uniform with $C"
680680
C = E
681681
end
682682
end
683683

684684
y = similar(vs, C)
685685
for i in eachindex(vs)
686686
if (vs[i] isa Number) & tofloat
687-
y[i] = float(vs[i])
687+
y[i] = float(vs[i]) #needed because copyto! can't convert Int to Float automatically
688688
else
689-
y[i] = vs[i]
689+
y[i] = vs[i]
690690
end
691691
end
692692

0 commit comments

Comments
 (0)