From e8964c899724aada9dec1105979a6a45863be186 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Mon, 3 Jul 2023 12:59:14 +0530 Subject: [PATCH] make AbstractArray reshape method less specific (#333) --- Project.toml | 4 ++-- src/OffsetArrays.jl | 2 +- test/Project.toml | 2 +- test/runtests.jl | 4 ++++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index 1e7b0fd6..fa188de4 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "OffsetArrays" uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" -version = "1.12.9" +version = "1.12.10" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" @@ -12,7 +12,7 @@ CatIndices = "0.2" DistributedArrays = "0.6" Documenter = "0.27" EllipsisNotation = "1" -FillArrays = "0.11, 0.13" +FillArrays = "0.11, 0.13, 1" StaticArrays = "1" julia = "0.7, 1" diff --git a/src/OffsetArrays.jl b/src/OffsetArrays.jl index 4c4ad416..2a03bf52 100644 --- a/src/OffsetArrays.jl +++ b/src/OffsetArrays.jl @@ -349,7 +349,7 @@ _similar_axes_or_length(AT, ax::I, ::I) where {I} = similar(AT, map(_indexlength # reshape accepts a single colon Base.reshape(A::AbstractArray, inds::OffsetAxis...) = reshape(A, inds) -function Base.reshape(A::AbstractArray, inds::Tuple{OffsetAxis,Vararg{OffsetAxis}}) +function Base.reshape(A::AbstractArray, inds::Tuple{Vararg{OffsetAxis}}) AR = reshape(no_offset_view(A), map(_indexlength, inds)) O = OffsetArray(AR, map(_offset, axes(AR), inds)) return _popreshape(O, axes(AR), _filterreshapeinds(inds)) diff --git a/test/Project.toml b/test/Project.toml index 096d6bf5..da67f5b9 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -18,5 +18,5 @@ CatIndices = "0.2" DistributedArrays = "0.6" Documenter = "0.27" EllipsisNotation = "1" -FillArrays = "0.11, 0.13" +FillArrays = "0.11, 0.13, 1" StaticArrays = "1" diff --git a/test/runtests.jl b/test/runtests.jl index e3afd1ab..2aacaad8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1893,6 +1893,10 @@ end A = OffsetArray(rand(4, 4), -1, -1) @test reshape(A, (:, )) == vec(A) @test reshape(A, :) == vec(A) + + # ensure that there's no ambiguity using AbstractArray and Tuple{Vararg{OffsetAxis}} + @test reshape(Fill(0), ()) === Fill(0) + @test reshape(Fill(2,6), big(2), :) == Fill(2, 2, 3) end @testset "permutedims" begin