Skip to content

Commit

Permalink
make AbstractArray reshape method less specific (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub authored Jul 3, 2023
1 parent 0929e07 commit e8964c8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion src/OffsetArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e8964c8

Please sign in to comment.