Skip to content

Commit c465e85

Browse files
Merge pull request #298 from visr/reshape
Add reshape back
2 parents 9d5afd5 + d1d0fc9 commit c465e85

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/componentarray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ function maybe_reshape(data, axs::AbstractAxis...)
262262
return reshape(data, shapes)
263263
end
264264

265-
function Base.reshape(parent::AbstractArray, dims::ComponentArrays.CombinedAxis...)
266-
reshape(parent, getfield.(dims, :array_axis))
265+
function Base.reshape(A::AbstractArray, axs::Tuple{CombinedAxis, Vararg{CombinedAxis}})
266+
reshape(A, _array_axis.(axs))
267267
end
268268

269269
# 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
@@ -291,12 +291,6 @@ end
291291
@test ca[Not(3)] == getdata(ca)[Not(3)]
292292
@test ca[Not(2:3)] == getdata(ca)[Not(2:3)]
293293

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

311305
# https://discourse.julialang.org/t/no-method-error-reshape-when-solving-ode-with-componentarrays-jl/126342
312306
x = ComponentVector(x=1.0, y=0.0, z=0.0)
313-
@test reshape(x, axes(x)...) isa ComponentVector
307+
@test reshape(x, axes(x)...) === x
308+
@test reshape(x, axes(x)) === x
314309
@test reshape(a, axes(ca)...) isa Vector{Float64}
315310

316311
# Issue #265: Multi-symbol indexing with matrix components
@@ -729,6 +724,7 @@ end
729724
# Issue #193
730725
# Make sure we aren't doing type piracy on `reshape`
731726
@test ndims(dropdims(ones(1,1), dims=(1,2))) == 0
727+
@test reshape([1]) == fill(1, ())
732728

733729
if VERSION >= v"1.9"
734730
# `stack` was introduced in Julia 1.9

0 commit comments

Comments
 (0)