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

Add compatibility for cat with dims kw argument #613

Merged
merged 3 commits into from
Aug 22, 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 @@ -292,6 +292,8 @@ 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]).

* `Compat.cat` with `dims` as keyword argument ([#27163])

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

* `fetch` for `Task`s ([#25940]).
Expand Down Expand Up @@ -663,6 +665,7 @@ includes this fix. Find the minimum version from there.
[#26670]: https://github.com/JuliaLang/julia/issues/26670
[#26850]: https://github.com/JuliaLang/julia/issues/26850
[#27077]: https://github.com/JuliaLang/julia/issues/27077
[#27163]: https://github.com/JuliaLang/julia/issues/27163
[#27253]: https://github.com/JuliaLang/julia/issues/27253
[#27258]: https://github.com/JuliaLang/julia/issues/27258
[#27298]: https://github.com/JuliaLang/julia/issues/27298
Expand Down
3 changes: 3 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1830,6 +1830,9 @@ end
if VERSION < v"0.7.0-DEV.4738"
Base.squeeze(A; dims=error("squeeze: keyword argument dims not assigned")) = squeeze(A, dims)
end
if VERSION < v"0.7.0-DEV.5165" # julia#27163
cat(X...; dims = throw(UndefKeywordError("cat: keyword argument dims not assigned"))) = Base.cat(dims, X...)
end

if !isdefined(Base, :selectdim) # 0.7.0-DEV.3976
export selectdim
Expand Down
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,13 @@ if VERSION < v"0.7.0-beta2.143"
@test_throws Exception squeeze([1,2])
end

# 0.7.0-DEV.5165
@test Compat.cat([1, 2], [3, 4, 5], dims = 1) == [1, 2, 3, 4, 5]
@test Compat.cat([1, 2], [3, 4], dims = 2) == [1 3; 2 4]
if VERSION < v"0.7.0-DEV.5165"
@test_throws UndefKeywordError Compat.cat([1, 2], [3, 4])
Copy link
Member

Choose a reason for hiding this comment

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

This throws again after removal of the respective deprecation for 1.0 (should be v"1.0.0-DEV.57"), so we could (should?) test there, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know, then we're effectively testing the implementation in base. At the time that I wrote it, It at least seemed weird to me. I'll defer to you and other members of Compat, but I don't see a reason to test code outside of Compat.

Copy link
Member

@martinholters martinholters Aug 21, 2018

Choose a reason for hiding this comment

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

Of, course, most (all?) our tests effectively test the implementation in Base on recent Julia. But here it is admittedly a little different, as we would do so more explicitly. I have no strong feelings about this. Maybe someone else wants to chime in? Otherwise I'll merge this as is tomorrow.

end

# 0.7.0-DEV.3976
let A = rand(5,5)
@test selectdim(A, 1, 3) == A[3, :]
Expand Down