JuliaAI / ScientificTypes.jl

An API for dispatching on the "scientific" type of data instead of the machine type
MIT License
96 stars 8 forks source link

Fix for empty arrays #108

Closed tlienart closed 3 years ago

tlienart commented 3 years ago

scitype_union is now

function scitype_union(A)
    isempty(A) && return scitype(eltype(A))
    reduce((a,b)->Union{a,b}, (scitype(el) for el in A))
end

before the first line wasn't there and so potentially there was a reduction over an empty array.

closes #107

codecov-commenter commented 3 years ago

Codecov Report

Merging #108 into master will increase coverage by 0.08%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #108      +/-   ##
==========================================
+ Coverage   96.96%   97.05%   +0.08%     
==========================================
  Files           2        2              
  Lines          33       34       +1     
==========================================
+ Hits           32       33       +1     
  Misses          1        1              
Impacted Files Coverage Δ
src/scitype.jl 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 8260ef8...58e7f48. Read the comment docs.

DilumAluthge commented 3 years ago

Maybe also add a test for Missing[]?

DilumAluthge commented 3 years ago

Thanks for such a quick fix!