Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mapslices with dims keyword argument #588

Merged
merged 1 commit into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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