Skip to content

Commit

Permalink
Use dims kw arg for dropdims
Browse files Browse the repository at this point in the history
dropdims is not a simple renaming of squeeze, but instead expects dims as a
keyword argument.
  • Loading branch information
galenlynch committed Aug 16, 2018
1 parent 9303f7d commit ce9bb7b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2006,7 +2006,7 @@ end

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

include("deprecated.jl")
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1932,5 +1932,11 @@ end

# 0.7.0-beta2.143
@test isdefined(Compat, :dropdims)
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)
end
end

nothing

0 comments on commit ce9bb7b

Please sign in to comment.