Skip to content

Commit

Permalink
mapslices with dims keyword argument (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholters authored Jul 11, 2018
1 parent af25a71 commit a4c6f22
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ Currently, the `@compat` macro supports the following syntaxes:
* `something` to get the first argument different from `nothing`, unwrapping those
of the `Some` type ([#27258]).

* `mapslices` with `dims` keyword argument ([#27828]).

## Renaming

* `Display` is now `AbstractDisplay` ([#24831]).
Expand Down Expand Up @@ -658,3 +660,4 @@ includes this fix. Find the minimum version from there.
[#27258]: https://github.com/JuliaLang/julia/issues/27258
[#27298]: https://github.com/JuliaLang/julia/issues/27298
[#27401]: https://github.com/JuliaLang/julia/issues/27401
[#27828]: https://github.com/JuliaLang/julia/issues/27828
6 changes: 6 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1966,6 +1966,12 @@ end
Base.split(s, splitter; limit=limit, keep=keepempty)
end

# https://github.com/JuliaLang/julia/pull/27828
if VERSION < v"0.7.0-beta.73"
Base.mapslices(f, A::AbstractArray; dims=error("required keyword argument `dims` missing")) =
mapslices(f, A, dims)
end

include("deprecated.jl")

end # module Compat
10 changes: 10 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1896,4 +1896,14 @@ let
@test Compat.split(str, r"\.+:\.+"; limit=3, keepempty=true) == ["a","ba","cba.:.:.dcba.:."]
end

# 0.7.0-beta.73
let a = rand(5,5)
s = mapslices(sort, a, dims=[1])
S = mapslices(sort, a, dims=[2])
for i = 1:5
@test s[:,i] == sort(a[:,i])
@test vec(S[i,:]) == sort(vec(a[i,:]))
end
end

nothing

0 comments on commit a4c6f22

Please sign in to comment.