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 1 commit
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 @@ -434,6 +434,8 @@ Currently, the `@compat` macro supports the following syntaxes:

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

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

## New macros

* `@__DIR__` has been added ([#18380])
Expand Down Expand Up @@ -671,3 +673,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
5 changes: 5 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,11 @@ 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"
dropdims(X; dims = throw(UndefKeywordError("dropdims: keyword argument dims not assigned"))) = squeeze(X, dims)
Copy link
Member

Choose a reason for hiding this comment

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

To be very pedantic, this should be squeeze(X, dims=dims) for VERSION > v"0.7.0-DEV.4738".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added support for that. This is one of my first PRs to compat: is the goal to have compat work properly on all versions of julia, even old development versions?

Copy link
Member

Choose a reason for hiding this comment

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

It's nice to have and if it can be done so easily, IMHO it's worth it.

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 Compat.dropdims(a; dims=3) == b
@test_throws UndefKeywordError Compat.dropdims(a)
Copy link
Member

Choose a reason for hiding this comment

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

...and then test without the Compat. qualification here.

end
end

nothing