Skip to content

Commit 5b939bf

Browse files
galenlynchmartinholters
authored andcommitted
Add compatibility for cat with dims kw argument (#613)
* Add compatibility for cat with dims kw argument cat(dims, Xs...) was deprecated to cat(Xs...; dims=dim) in [#27163], but as described in #612 support for the new signature is missing in Compat. Fixes #612 [#27163]: https://github.com/JuliaLang/julia/issue/27163
1 parent 268aae6 commit 5b939bf

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ Currently, the `@compat` macro supports the following syntaxes:
292292

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

295+
* `Compat.cat` with `dims` as keyword argument ([#27163])
296+
295297
* Single-argument `permutedims(x)` for matrices and vectors ([#24839]).
296298

297299
* `fetch` for `Task`s ([#25940]).
@@ -663,6 +665,7 @@ includes this fix. Find the minimum version from there.
663665
[#26670]: https://github.com/JuliaLang/julia/issues/26670
664666
[#26850]: https://github.com/JuliaLang/julia/issues/26850
665667
[#27077]: https://github.com/JuliaLang/julia/issues/27077
668+
[#27163]: https://github.com/JuliaLang/julia/issues/27163
666669
[#27253]: https://github.com/JuliaLang/julia/issues/27253
667670
[#27258]: https://github.com/JuliaLang/julia/issues/27258
668671
[#27298]: https://github.com/JuliaLang/julia/issues/27298

src/Compat.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,6 +1830,9 @@ end
18301830
if VERSION < v"0.7.0-DEV.4738"
18311831
Base.squeeze(A; dims=error("squeeze: keyword argument dims not assigned")) = squeeze(A, dims)
18321832
end
1833+
if VERSION < v"0.7.0-DEV.5165" # julia#27163
1834+
cat(X...; dims = throw(UndefKeywordError("cat: keyword argument dims not assigned"))) = Base.cat(dims, X...)
1835+
end
18331836

18341837
if !isdefined(Base, :selectdim) # 0.7.0-DEV.3976
18351838
export selectdim

test/runtests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,6 +1652,13 @@ if VERSION < v"0.7.0-beta2.143"
16521652
@test_throws Exception squeeze([1,2])
16531653
end
16541654

1655+
# 0.7.0-DEV.5165
1656+
@test Compat.cat([1, 2], [3, 4, 5], dims = 1) == [1, 2, 3, 4, 5]
1657+
@test Compat.cat([1, 2], [3, 4], dims = 2) == [1 3; 2 4]
1658+
if VERSION < v"0.7.0-DEV.5165"
1659+
@test_throws UndefKeywordError Compat.cat([1, 2], [3, 4])
1660+
end
1661+
16551662
# 0.7.0-DEV.3976
16561663
let A = rand(5,5)
16571664
@test selectdim(A, 1, 3) == A[3, :]

0 commit comments

Comments
 (0)