From 9d629d1ecc64a7c3650f41a6782b70cf7e632763 Mon Sep 17 00:00:00 2001 From: Galen Lynch Date: Sun, 12 Aug 2018 09:40:21 -0400 Subject: [PATCH 1/2] 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 --- README.md | 3 +++ src/Compat.jl | 3 +++ test/runtests.jl | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/README.md b/README.md index e8bc94440..1dc16e0a6 100644 --- a/README.md +++ b/README.md @@ -294,6 +294,8 @@ Currently, the `@compat` macro supports the following syntaxes: * `squeeze` with `dims` as keyword argument ([#26660]). +* `cat` with `dims` as keyword argument ([#27163]) + * Single-argument `permutedims(x)` for matrices and vectors ([#24839]). * `fetch` for `Task`s ([#25940]). @@ -661,6 +663,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 diff --git a/src/Compat.jl b/src/Compat.jl index 54adc0724..1315bfeca 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index 1fde8d6a1..c0120ec50 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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]) +end + # 0.7.0-DEV.3976 let A = rand(5,5) @test selectdim(A, 1, 3) == A[3, :] From 25d25ea7bda031506743a5d90599f298bcc68311 Mon Sep 17 00:00:00 2001 From: Galen Lynch Date: Mon, 20 Aug 2018 11:39:44 -0400 Subject: [PATCH 2/2] Clarify that Compat's `cat` is not exported in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1dc16e0a6..58c4cf8c6 100644 --- a/README.md +++ b/README.md @@ -294,7 +294,7 @@ Currently, the `@compat` macro supports the following syntaxes: * `squeeze` with `dims` as keyword argument ([#26660]). -* `cat` with `dims` as keyword argument ([#27163]) +* `Compat.cat` with `dims` as keyword argument ([#27163]) * Single-argument `permutedims(x)` for matrices and vectors ([#24839]).