Skip to content

Commit ee481b4

Browse files
Merge pull request #297 from SciML/reshape
Fix CombinedAxis fallback reshape on AbstractArray
2 parents 1db5469 + 961984f commit ee481b4

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ComponentArrays"
22
uuid = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
33
authors = ["Jonnie Diegelman <[email protected]>"]
4-
version = "0.15.24"
4+
version = "0.15.25"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

src/componentarray.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ 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))
260+
end
261+
258262
# Recurse through nested ViewAxis types to find the last index
259263
last_index(x) = last(x)
260264
last_index(x::ViewAxis) = last_index(viewindex(x))

test/runtests.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,10 @@ end
306306
@test cmat3[:c, :b] == reshape(cmat3check[6:11, 2:5], 3, 2, 4)
307307
@test cmat3[:c, :c] == reshape(cmat3check[6:11, 6:11], 3, 2, 3, 2)
308308

309-
@test_broken reshape(a, axes(ca)...) isa Vector{Float64}
309+
# https://discourse.julialang.org/t/no-method-error-reshape-when-solving-ode-with-componentarrays-jl/126342
310+
x = ComponentVector(x=1.0, y=0.0, z=0.0)
311+
@test reshape(x, axes(x)...) isa ComponentVector
312+
@test reshape(a, axes(ca)...) isa Vector{Float64}
310313

311314
# Issue #265: Multi-symbol indexing with matrix components
312315
@test ca2.c[[:a, :b]].b isa AbstractMatrix

0 commit comments

Comments
 (0)