Skip to content

Commit

Permalink
fix: promote vs to a Union{Bool, ...} whenever a boolean value is…
Browse files Browse the repository at this point in the history
… present
  • Loading branch information
ven-k committed Aug 22, 2023
1 parent a69570a commit c33e4cb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ function promote_to_concrete(vs; tofloat = true, use_union = false)
I = Int8
has_int = false
has_array = false
has_bool = false
array_T = nothing
for v in vs
if v isa AbstractArray
Expand All @@ -692,16 +693,22 @@ function promote_to_concrete(vs; tofloat = true, use_union = false)
has_int = true
I = promote_type(I, E)
end
if E <: Bool
has_bool = true
end
end
if tofloat && !has_array
if tofloat && !has_array && !has_bool
C = float(C)
elseif has_array || (use_union && has_int && C !== I)
elseif has_array || (use_union && has_int && C !== I) || has_bool
if has_array
C = Union{C, array_T}
end
if has_int
C = Union{C, I}
end
if has_bool
C = Union{C, Bool}
end
return copyto!(similar(vs, C), vs)
end
convert.(C, vs)
Expand Down

0 comments on commit c33e4cb

Please sign in to comment.