Skip to content

Commit 024f113

Browse files
committed
Fix #1561
1 parent 7c7b98d commit 024f113

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/utils.jl

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,20 +481,31 @@ function promote_to_concrete(vs; tofloat=true, use_union=false)
481481
vs
482482
else
483483
C = typeof(first(vs))
484-
has_int = false
485484
I = Int8
485+
has_int = false
486+
has_array = false
487+
array_T = nothing
486488
for v in vs
489+
if v isa AbstractArray
490+
has_array = true
491+
array_T = typeof(v)
492+
end
487493
E = eltype(v)
488494
C = promote_type(C, E)
489495
if E <: Integer
490496
has_int = true
491497
I = promote_type(I, E)
492498
end
493499
end
494-
if tofloat
500+
if tofloat && !has_array
495501
C = float(C)
496-
elseif use_union && has_int && C !== I
497-
C = Union{C, I}
502+
elseif has_array || (use_union && has_int && C !== I)
503+
if has_array
504+
C = Union{C, array_T}
505+
end
506+
if has_int
507+
C = Union{C, I}
508+
end
498509
return copyto!(similar(vs, C), vs)
499510
end
500511
convert.(C, vs)

0 commit comments

Comments
 (0)