diff --git a/src/array_interface.jl b/src/array_interface.jl index c9060eb..f973447 100644 --- a/src/array_interface.jl +++ b/src/array_interface.jl @@ -10,6 +10,8 @@ Base.axes(x::ComponentArray) = CombinedAxis.(getaxes(x), axes(getdata(x))) Base.reinterpret(::Type{T}, x::ComponentArray, args...) where T = ComponentArray(reinterpret(T, getdata(x), args...), getaxes(x)) +Base.reshape(A::AbstractArray, axs::Tuple{CombinedAxis, Vararg{CombinedAxis}}) = reshape(A, _array_axis.(axs)) + ArrayInterface.indices_do_not_alias(::Type{ComponentArray{T,N,A,Axes}}) where {T,N,A,Axes} = ArrayInterface.indices_do_not_alias(A) ArrayInterface.instances_do_not_alias(::Type{ComponentArray{T,N,A,Axes}}) where {T,N,A,Axes} = ArrayInterface.instances_do_not_alias(A) diff --git a/test/runtests.jl b/test/runtests.jl index f281f61..8dc330e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -290,10 +290,9 @@ end @test ca[Not(2:3)] == getdata(ca)[Not(2:3)] # Issue #123 - # We had to revert this because there is no way to work around - # OffsetArrays' type piracy without introducing type piracy - # ourselves because `() isa Tuple{N, <:CombinedAxis} where {N}` - # @test reshape(a, axes(ca)...) isa Vector{Float64} + @test reshape(a, axes(ca)...) isa Vector{Float64} + @teset reshape(ca, axes(ca)) === ca + @teset reshape(ca, axes(ca)...) === ca # Issue #248: Indexing ComponentMatrix with FlatAxis components @test cmat3[:a, :a] == cmat3check[1, 1] @@ -306,8 +305,6 @@ end @test cmat3[:c, :b] == reshape(cmat3check[6:11, 2:5], 3, 2, 4) @test cmat3[:c, :c] == reshape(cmat3check[6:11, 6:11], 3, 2, 3, 2) - @test_broken reshape(a, axes(ca)...) isa Vector{Float64} - # Issue #265: Multi-symbol indexing with matrix components @test ca2.c[[:a, :b]].b isa AbstractMatrix end