# No method error (reshape) when solving ODE with ComponentArrays.jl

**URL:** <https://discourse.julialang.org/t/no-method-error-reshape-when-solving-ode-with-componentarrays-jl/126342>\
**Category:** General Usage\
**Tags:** componentarrays\
**Created:** [February 26, 2025, 2:58pm UTC](https://discourse.julialang.org/t/no-method-error-reshape-when-solving-ode-with-componentarrays-jl/126342 "2025-02-26T14:58:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wen-Wei\_Tseng](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wen-wei_tseng/32/28839_2.png) [@Wen-Wei\_Tseng](https://discourse.julialang.org/u/Wen-Wei_Tseng)\
**Post date:** [February 26, 2025, 2:58pm UTC](https://discourse.julialang.org/t/no-method-error-reshape-when-solving-ode-with-componentarrays-jl/126342/1 "2025-02-26T14:58:37Z")

</div>

Hi, I was using ComponentArrays.jl to solve the ODE problem in the README and got an error.

```julia
using ComponentArrays
using OrdinaryDiffEq
using SimpleUnPack: @unpack

tspan = (0.0, 20.0)

function lorenz!(D, u, p, t; f=0.0)
    @unpack σ, ρ, β = p
    @unpack x, y, z = u

    D.x = σ*(y - x)
    D.y = x*(ρ - z) - y - f
    D.z = x*y - β*z
    return nothing
end

lorenz_p = ComponentVector(σ=10.0, ρ=28.0, β=8/3)
lorenz_ic = ComponentVector(x=1.0, y=0.0, z=0.0)
lorenz_prob = ODEProblem(lorenz!, lorenz_ic, tspan, lorenz_p)

lorenz_sol = solve(lorenz_prob) # Method error here

```

The error was

```julia
ERROR: MethodError: no method matching reshape(::UnitRange{Int64}, ::Tuple{ComponentArrays.CombinedAxis{Axis{(x = 1, y = 2, z = 3)}, Base.OneTo{Int64}}})
The function `reshape` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  reshape(::AbstractArray, ::Tuple{Vararg{Union{Colon, Int64}}})
   @ Base reshapedarray.jl:129
  reshape(::AbstractArray, ::NTuple{N, Int64} where N)
   @ Base reshapedarray.jl:122
  reshape(::AbstractArray, ::Tuple{Union{Integer, Base.OneTo}, Vararg{Union{Integer, Base.OneTo}}})
   @ Base reshapedarray.jl:121
  ...

Stacktrace:
  [1] reshape(parent::UnitRange{Int64}, dims::ComponentArrays.CombinedAxis{Axis{(x = 1, y = 2, z = 3)}, Base.OneTo{Int64}})
    @ Base .\reshapedarray.jl:120
  [2] finite_difference_jacobian!(J::Matrix{…}, f::SciMLBase.UJacobianWrapper{…}, x::ComponentVector{…}, cache::FiniteDiff.JacobianCache{…}, f_in::ComponentVector{…}; relstep::Float64, absstep::Float64, colorvec::UnitRange{…}, sparsity::Nothing, dir::Int64)
    @ FiniteDiff E:\.julia\packages\FiniteDiff\EBPBu\src\jacobians.jl:419
  [3] jacobian_finitediff_forward!(J::Matrix{…}, f::Function, x::ComponentVector{…}, jac_config::FiniteDiff.JacobianCache{…}, forwardcache::ComponentVector{…}, integrator::OrdinaryDiffEqCore.ODEIntegrator{…})
    @ OrdinaryDiffEqDifferentiation E:\.julia\packages\OrdinaryDiffEqDifferentiation\6Bzim\src\derivative_wrappers.jl:219
  [4] jacobian!(J::Matrix{…}, f::SciMLBase.UJacobianWrapper{…}, x::ComponentVector{…}, fx::ComponentVector{…}, integrator::OrdinaryDiffEqCore.ODEIntegrator{…}, jac_config::FiniteDiff.JacobianCache{…})
    @ OrdinaryDiffEqDifferentiation E:\.julia\packages\OrdinaryDiffEqDifferentiation\6Bzim\src\derivative_wrappers.jl:250
  [5] calc_J!(J::Matrix{…}, integrator::OrdinaryDiffEqCore.ODEIntegrator{…}, cache::OrdinaryDiffEqRosenbrock.Rosenbrock23Cache{…}, next_step::Bool)
    @ OrdinaryDiffEqDifferentiation E:\.julia\packages\OrdinaryDiffEqDifferentiation\6Bzim\src\derivative_utils.jl:152
  [6] calc_W!
    @ E:\.julia\packages\OrdinaryDiffEqDifferentiation\6Bzim\src\derivative_utils.jl:557 [inlined]
  [7] calc_W!
    @ E:\.julia\packages\OrdinaryDiffEqDifferentiation\6Bzim\src\derivative_utils.jl:495 [inlined]
  [8] calc_rosenbrock_differentiation!
    @ E:\.julia\packages\OrdinaryDiffEqDifferentiation\6Bzim\src\derivative_utils.jl:631 [inlined]
  [9] perform_step!(integrator::OrdinaryDiffEqCore.ODEIntegrator{…}, cache::OrdinaryDiffEqRosenbrock.Rosenbrock23Cache{…}, repeat_step::Bool)
    @ OrdinaryDiffEqRosenbrock E:\.julia\packages\OrdinaryDiffEqRosenbrock\0G2ZF\src\rosenbrock_perform_step.jl:46
 [10] perform_step!(integrator::OrdinaryDiffEqCore.ODEIntegrator{…}, cache::OrdinaryDiffEqCore.DefaultCache{…}, repeat_step::Bool)
    @ OrdinaryDiffEqCore E:\.julia\packages\OrdinaryDiffEqCore\yTEch\src\perform_step\composite_perform_step.jl:145
 [11] perform_step!
    @ E:\.julia\packages\OrdinaryDiffEqCore\yTEch\src\perform_step\composite_perform_step.jl:138 [inlined]
 [12] solve!(integrator::OrdinaryDiffEqCore.ODEIntegrator{…})
    @ OrdinaryDiffEqCore E:\.julia\packages\OrdinaryDiffEqCore\yTEch\src\solve.jl:620
 [13] __solve(::ODEProblem{…}, ::CompositeAlgorithm{…}; kwargs::@Kwargs{…})
    @ OrdinaryDiffEqCore E:\.julia\packages\OrdinaryDiffEqCore\yTEch\src\solve.jl:7
 [14] __solve
    @ E:\.julia\packages\OrdinaryDiffEqCore\yTEch\src\solve.jl:1 [inlined]
 [15] #solve_call#35
    @ E:\.julia\packages\DiffEqBase\HGITF\src\solve.jl:635 [inlined]
 [16] solve_call
    @ E:\.julia\packages\DiffEqBase\HGITF\src\solve.jl:592 [inlined]
 [17] #solve_up#44
    @ E:\.julia\packages\DiffEqBase\HGITF\src\solve.jl:1128 [inlined]
 [18] solve_up
    @ E:\.julia\packages\DiffEqBase\HGITF\src\solve.jl:1106 [inlined]
 [19] #solve#42
    @ E:\.julia\packages\DiffEqBase\HGITF\src\solve.jl:1045 [inlined]
 [20] solve
    @ E:\.julia\packages\DiffEqBase\HGITF\src\solve.jl:1033 [inlined]
 [21] #__solve#3
    @ E:\.julia\packages\OrdinaryDiffEqDefault\kOV75\src\default_alg.jl:48 [inlined]
 [22] __solve
    @ E:\.julia\packages\OrdinaryDiffEqDefault\kOV75\src\default_alg.jl:47 [inlined]
 [23] #__solve#63
    @ E:\.julia\packages\DiffEqBase\HGITF\src\solve.jl:1437 [inlined]
 [24] __solve
    @ E:\.julia\packages\DiffEqBase\HGITF\src\solve.jl:1428 [inlined]
 [25] #solve_call#35
    @ E:\.julia\packages\DiffEqBase\HGITF\src\solve.jl:635 [inlined]
 [26] solve_call
    @ E:\.julia\packages\DiffEqBase\HGITF\src\solve.jl:592 [inlined]
 [27] #solve_up#44
    @ E:\.julia\packages\DiffEqBase\HGITF\src\solve.jl:1112 [inlined]
 [28] solve_up
    @ E:\.julia\packages\DiffEqBase\HGITF\src\solve.jl:1106 [inlined]
 [29] #solve#42
    @ E:\.julia\packages\DiffEqBase\HGITF\src\solve.jl:1043 [inlined]
 [30] solve(::ODEProblem{…})
    @ DiffEqBase E:\.julia\packages\DiffEqBase\HGITF\src\solve.jl:1033
 [31] top-level scope
    @ d:\github\ca-ode\mwe.jl:21
Some type information was truncated. Use `show(err)` to see complete types.

```

Packages:

```julia
(ca-ode) pkg> st
Status `D:\github\ca-ode\Project.toml`
  [b0b7db55] ComponentArrays v0.15.24
  [1dea7af3] OrdinaryDiffEq v6.91.0
  [ce78b400] SimpleUnPack v1.1.0

```

System: Julia version 1.11.3, Windows 11 24H2

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [March 1, 2025, 2:44pm UTC](https://discourse.julialang.org/t/no-method-error-reshape-when-solving-ode-with-componentarrays-jl/126342/2 "2025-03-01T14:44:56Z")

</div>

This is fixed in a patch that should release later today [Fix CombinedAxis fallback reshape on AbstractArray by ChrisRackauckas · Pull Request #297 · SciML/ComponentArrays.jl · GitHub](https://github.com/SciML/ComponentArrays.jl/pull/297)
