milankl / BitInformation.jl

Information between bits and bytes.
MIT License
33 stars 3 forks source link

Check for NaNs and raise warning #47

Open milankl opened 1 year ago

milankl commented 1 year ago

As just discussed with @observingClouds and @ayoubft, we should have a check that elements in an array have only finite values and raise a warning if. While the algorithm does not care about the meaning of the bitpatterns the user may not get what they expect if there are many NaNs in the dataset. Example, currently we have

julia> A = rand(100,100);
julia> A[1] = NaN
NaN

julia> bitinformation(A)
64-element Vector{Float64}:
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 0.0
 ⋮

but we shoud throw something like

julia> for a in A
           if !isfinite(a)
               @warn "Non-finite value detected."
           end
       end
┌ Warning: Non-finite value detected.
└ @ Main REPL[8]:3