Skip to content

Commit

Permalink
Implemented additional _missing methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaBillson committed Aug 29, 2023
1 parent 05bd274 commit c803f35
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/skipmissing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,12 @@ function Base.iterate(itr::SkipMissingVal, state...)
item, state
end

_missing(x, itr) = x == missingval(itr)
_missing(x, itr) = isequal(x, missingval(itr))

_missing(x::Missing, itr) = true

_missing(x::Nothing, itr) = true

function _missing(x::AbstractFloat, itr)
if isnothing(missingval(itr))
return false
elseif isnan(missingval(itr))
return isnan(x)
else
return x == missingval(itr)
end
end

Base.IndexStyle(::Type{<:SkipMissingVal{T}}) where {T} = IndexStyle(T)
Base.eachindex(itr::SkipMissingVal) =
Iterators.filter(i -> !_missing(@inbounds(itr.x[i]), itr), eachindex(itr.x))
Expand Down

0 comments on commit c803f35

Please sign in to comment.