Skip to content

Commit

Permalink
Merge pull request #44 from oxinabox/ox/mrkw
Browse files Browse the repository at this point in the history
make mapreduce pass on kwargs
  • Loading branch information
mcabbott authored Feb 17, 2021
2 parents 9130e91 + 298f81e commit 44e2320
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "AxisKeys"
uuid = "94b1ba4f-4ee9-5380-92f1-94cde586c3c5"
license = "MIT"
version = "0.1.10"
version = "0.1.11"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down
2 changes: 1 addition & 1 deletion src/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ tuple_flatten(x::Tuple, ys::Tuple...) = (x..., tuple_flatten(ys...)...)
tuple_flatten() = ()

function Base.mapreduce(f, op, A::KeyedArray; dims=:, kwargs...) # sum, prod, etc
dims === Colon() && return mapreduce(f, op, parent(A))
dims === Colon() && return mapreduce(f, op, parent(A); kwargs...)
numerical_dims = NamedDims.dim(A, dims)
data = mapreduce(f, op, parent(A); dims=numerical_dims, kwargs...)
new_keys = ntuple(d -> d in numerical_dims ? Base.OneTo(1) : axiskeys(A,d), ndims(A))
Expand Down
6 changes: 5 additions & 1 deletion test/_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ A3 = wrapdims(rand(Int8, 3,4,2), r='a':'c', c=2:5, p=[10.0, 20.0])
@test reshape(M, (4,3)) isa Array
@test reshape(M, (2,:)) isa Array
end

end
@testset "Regression test against https://github.com/mcabbott/AxisKeys.jl/issues/43" begin
z = KeyedArray(zeros(3); foo=[:a, :b, :c])
@test mapreduce(identity, +, z; init=10) == 10
end

@testset "sort" begin

@test sort(V)(20) == V(20)
Expand Down

2 comments on commit 44e2320

@mcabbott
Copy link
Owner Author

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/30248

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.1.11 -m "<description of version>" 44e2320eba9b6411bf5bf9ae7ab0ba7fd69b4afc
git push origin v0.1.11

Please sign in to comment.