Skip to content

Commit

Permalink
Fix type assertion in _filter_helper (#3155)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkamins authored Sep 19, 2022
1 parent 4b40aba commit b1c990c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
([#3081](https://github.com/JuliaData/DataFrames.jl/pull/3081))
* Make `subset` preserves group ordering when `ungroup=false` like `subset!` already does
([#3094](https://github.com/JuliaData/DataFrames.jl/pull/3094))
* Fix overly restrictive type assertion in `filter` and `filter!`
([#3155](https://github.com/JuliaData/DataFrames.jl/pull/3155))

## Performance

Expand Down
4 changes: 2 additions & 2 deletions src/abstractdataframe/abstractdataframe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ end
return view ? Base.view(df, rowidxs, :) : df[rowidxs, :]
end

_filter_helper(f, cols...)::BitVector = ((x...) -> f(x...)::Bool).(cols...)
_filter_helper(f, cols...)::AbstractVector{Bool} = ((x...) -> f(x...)::Bool).(cols...)

@inline function Base.filter((cols, f)::Pair{AsTable}, df::AbstractDataFrame;
view::Bool=false)
Expand All @@ -1155,7 +1155,7 @@ _filter_helper(f, cols...)::BitVector = ((x...) -> f(x...)::Bool).(cols...)
return view ? Base.view(df, rowidxs, :) : df[rowidxs, :]
end

_filter_helper_astable(f, nti::Tables.NamedTupleIterator)::BitVector = (x -> f(x)::Bool).(nti)
_filter_helper_astable(f, nti::Tables.NamedTupleIterator)::AbstractVector{Bool} = (x -> f(x)::Bool).(nti)

"""
filter!(fun, df::AbstractDataFrame)
Expand Down

0 comments on commit b1c990c

Please sign in to comment.