Skip to content

Commit

Permalink
Merge pull request #92 from invenia/rf/filter-fix
Browse files Browse the repository at this point in the history
Filter return type fix
  • Loading branch information
rofinn authored Nov 9, 2020
2 parents 663a709 + 017892d commit 7562ae2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/filter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ end
function apply(data::AbstractArray{Union{T, Missing}}, f::Filter; dims) where T
d = dim(data, dims)
mask = map(f.func, eachslice(data; dims=d))
# use selectdim to reduce along dimension d using our mask, but call collect
# because we don't want to return a view
return collect(selectdim(data, d, mask))
# use selectdim to reduce along dimension d using our mask, but call copy
# because we don't want to return a view and collect may change the return type
return copy(selectdim(data, d, mask))
end

apply(data::AbstractArray, f::Filter) = disallowmissing(data)
Expand Down
4 changes: 3 additions & 1 deletion test/filter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@

@testset "rows" begin
result = apply(aa, Filter(); dims=:rows)
expected = m[[1, 4, 5], :]
expected = aa[[1, 4, 5], :]

@test isa(result, AxisArray)
@test isequal(result, expected)
@test isequal(result, Impute.filter(aa; dims=:rows))
@test isequal(collect(result'), Impute.filter(collect(aa'); dims=:cols))
Expand All @@ -155,6 +156,7 @@
result = apply(aa, Filter(); dims=:cols)
expected = copy(aa)[:, 3:4]

@test isa(result, AxisArray)
@test isequal(result, expected)
@test isequal(result, Impute.filter(aa; dims=:cols))
@test isequal(collect(result'), Impute.filter(collect(aa'); dims=:rows))
Expand Down

2 comments on commit 7562ae2

@rofinn
Copy link
Member Author

@rofinn rofinn commented on 7562ae2 Nov 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/24812

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.0 -m "<description of version>" 7562ae22afe2e1e8623bb1aa87f841117b47f6a0
git push origin v0.6.0

Please sign in to comment.