Skip to content

Commit fa05fd0

Browse files
committed
Add is_good_array for non-Float32/64
1 parent f1aad67 commit fa05fd0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Utils.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,14 @@ end
7676
# Fastest way to check for NaN in an array.
7777
# Thanks @mikmore https://discourse.julialang.org/t/fastest-way-to-check-for-inf-or-nan-in-an-array/76954/33?u=milescranmer
7878
is_bad_array(x) = !is_good_array(x)
79-
function is_good_array(x::AbstractArray{T}) where {T}
79+
function is_good_array(x::AbstractArray{T}) where {T<:Union{Float32,Float64}}
8080
cumulator = zero(T)
8181
@turbo safe = false for i in eachindex(x)
8282
cumulator += x[i] * 0
8383
end
8484
return cumulator == 0
8585
end
86+
is_good_array(x) = sum(xi -> xi * zero(xi), x) == zero(eltype(x))
8687

8788
isgood(x::T) where {T<:Number} = !(isnan(x) || !isfinite(x))
8889
isgood(x) = true

0 commit comments

Comments
 (0)