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

squeeze is now dropdims #618

Merged
merged 3 commits into from
Aug 21, 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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,6 @@ Currently, the `@compat` macro supports the following syntaxes:

* `selectdim` to obtain a view of an array with a specified index for a specified dimension ([#26009]).

* `squeeze` with `dims` as keyword argument ([#26660]).

* Single-argument `permutedims(x)` for matrices and vectors ([#24839]).

* `fetch` for `Task`s ([#25940]).
Expand Down Expand Up @@ -434,6 +432,8 @@ Currently, the `@compat` macro supports the following syntaxes:

* `realmin` and `realmax` are now `floatmin` and `floatmax` ([#28302])

* `squeeze` is now `dropdims` ([#28303], [#26660]).

## New macros

* `@__DIR__` has been added ([#18380])
Expand Down Expand Up @@ -671,3 +671,4 @@ includes this fix. Find the minimum version from there.
[#27828]: https://github.com/JuliaLang/julia/issues/27828
[#27834]: https://github.com/JuliaLang/julia/issues/27834
[#28302]: https://github.com/JuliaLang/julia/issues/28302
[#28303]: https://github.com/JuliaLang/julia/issues/28303
19 changes: 19 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,25 @@ if VERSION < v"0.7.0-beta2.169"
export floatmin, floatmax
end

# https://github.com/JuliaLang/julia/pull/28303
if VERSION < v"0.7.0-beta2.143"
export dropdims
# https://github.com/JuliaLang/julia/pull/26660
if VERSION >= v"0.7.0-DEV.4738"
dropdims(
X;
dims = throw(
UndefKeywordError("dropdims: keyword argument dims not assigned"))
) = squeeze(X, dims = dims)
else
dropdims(
X;
dims = throw(
UndefKeywordError("dropdims: keyword argument dims not assigned"))
) = squeeze(X, dims)
end
end

include("deprecated.jl")

end # module Compat
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1935,4 +1935,12 @@ end
@test floatmax(Float32) == @eval $(Core.Intrinsics.bitcast(Float32, 0x7f7fffff))
@test floatmin(zero(Float64)) == floatmin(Float64)

# 0.7.0-beta2.143
if VERSION < v"0.7.0-beta2.143"
let a = reshape(Vector(1:4),(2,2,1,1)), b = reshape(Vector(1:4), (2,2,1))
@test dropdims(a; dims=3) == b
@test_throws UndefKeywordError dropdims(a)
end
end

nothing