Skip to content

Commit d1d0fc9

Browse files
committed
Add reshape back
1 parent ee481b4 commit d1d0fc9

2 files changed

Lines changed: 5 additions & 9 deletions

File tree

src/componentarray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ function maybe_reshape(data, axs::AbstractAxis...)
255255
return reshape(data, shapes)
256256
end
257257

258-
function Base.reshape(parent::AbstractArray, dims::ComponentArrays.CombinedAxis...)
259-
reshape(parent, getfield.(dims, :array_axis))
258+
function Base.reshape(A::AbstractArray, axs::Tuple{CombinedAxis, Vararg{CombinedAxis}})
259+
reshape(A, _array_axis.(axs))
260260
end
261261

262262
# Recurse through nested ViewAxis types to find the last index

test/runtests.jl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,6 @@ end
289289
@test ca[Not(3)] == getdata(ca)[Not(3)]
290290
@test ca[Not(2:3)] == getdata(ca)[Not(2:3)]
291291

292-
# Issue #123
293-
# We had to revert this because there is no way to work around
294-
# OffsetArrays' type piracy without introducing type piracy
295-
# ourselves because `() isa Tuple{N, <:CombinedAxis} where {N}`
296-
# @test reshape(a, axes(ca)...) isa Vector{Float64}
297-
298292
# Issue #248: Indexing ComponentMatrix with FlatAxis components
299293
@test cmat3[:a, :a] == cmat3check[1, 1]
300294
@test cmat3[:a, :b] == cmat3check[1, 2:5]
@@ -308,7 +302,8 @@ end
308302

309303
# https://discourse.julialang.org/t/no-method-error-reshape-when-solving-ode-with-componentarrays-jl/126342
310304
x = ComponentVector(x=1.0, y=0.0, z=0.0)
311-
@test reshape(x, axes(x)...) isa ComponentVector
305+
@test reshape(x, axes(x)...) === x
306+
@test reshape(x, axes(x)) === x
312307
@test reshape(a, axes(ca)...) isa Vector{Float64}
313308

314309
# Issue #265: Multi-symbol indexing with matrix components
@@ -727,6 +722,7 @@ end
727722
# Issue #193
728723
# Make sure we aren't doing type piracy on `reshape`
729724
@test ndims(dropdims(ones(1,1), dims=(1,2))) == 0
725+
@test reshape([1]) == fill(1, ())
730726

731727
if VERSION >= v"1.9"
732728
# `stack` was introduced in Julia 1.9

0 commit comments

Comments
 (0)