From a0dd415d85a43e28834c0c9649ba0ccfc42f4569 Mon Sep 17 00:00:00 2001 From: erich-9 Date: Sat, 2 Mar 2024 11:12:50 +0100 Subject: [PATCH 1/4] Always return a value in 1-d circshift! of abstractarray.jl --- base/abstractarray.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/abstractarray.jl b/base/abstractarray.jl index bdbcbe4d081a4..a9431197932dd 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -3656,9 +3656,9 @@ end ## 1-d circshift ## function circshift!(a::AbstractVector, shift::Integer) n = length(a) - n == 0 && return + n == 0 && return a shift = mod(shift, n) - shift == 0 && return + shift == 0 && return a l = lastindex(a) reverse!(a, firstindex(a), l-shift) reverse!(a, l-shift+1, lastindex(a)) From e6fa5a7d8373272ae562a78c7e4bb4f8ae857471 Mon Sep 17 00:00:00 2001 From: Erich Neun Date: Sat, 2 Mar 2024 12:09:07 +0100 Subject: [PATCH 2/4] Add some tests --- test/arrayops.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/arrayops.jl b/test/arrayops.jl index a07e631e639f9..1b01b4dba1ab4 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -797,6 +797,14 @@ end oa = OffsetVector(copy(a), -1) @test circshift!(oa, 1) === oa @test oa == circshift(OffsetVector(a, -1), 1) + + # 1d circshift! (https://github.com/JuliaLang/julia/pull/53554) + a = [] + @test circshift!(a, 1) === a + @test circshift!(a, 1) == [] + a = [1:5;] + @test circshift!(a, 10) === a + @test circshift!(a, 10) == [1:5;] end @testset "circcopy" begin From 65a52f14cdfa24b2d4062a5a644126a07ac7a051 Mon Sep 17 00:00:00 2001 From: erich-9 Date: Sat, 2 Mar 2024 17:51:11 +0100 Subject: [PATCH 3/4] Update test/arrayops.jl Co-authored-by: Sukera <11753998+Seelengrab@users.noreply.github.com> --- test/arrayops.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/arrayops.jl b/test/arrayops.jl index 1b01b4dba1ab4..1f8d40b565267 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -798,7 +798,7 @@ end @test circshift!(oa, 1) === oa @test oa == circshift(OffsetVector(a, -1), 1) - # 1d circshift! (https://github.com/JuliaLang/julia/pull/53554) + # 1d circshift! (#53554) a = [] @test circshift!(a, 1) === a @test circshift!(a, 1) == [] From 8d2df400152af36f1e9f0f370428d6cff2752e19 Mon Sep 17 00:00:00 2001 From: erich-9 Date: Sat, 2 Mar 2024 19:27:44 +0100 Subject: [PATCH 4/4] Update test/arrayops.jl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mosè Giordano --- test/arrayops.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/arrayops.jl b/test/arrayops.jl index 1f8d40b565267..566dd44b8dcd9 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -804,7 +804,7 @@ end @test circshift!(a, 1) == [] a = [1:5;] @test circshift!(a, 10) === a - @test circshift!(a, 10) == [1:5;] + @test circshift!(a, 10) == 1:5 end @testset "circcopy" begin