# Nested ArrayPartition cause reduce over an empty collection

**URL:** <https://discourse.julialang.org/t/nested-arraypartition-cause-reduce-over-an-empty-collection/25424>\
**Category:** General Usage\
**Tags:** diffeq\
**Created:** [June 18, 2019, 8:40pm UTC](https://discourse.julialang.org/t/nested-arraypartition-cause-reduce-over-an-empty-collection/25424 "2019-06-18T20:40:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shipengcheng1230](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shipengcheng1230/32/4089_2.png) [@shipengcheng1230](https://discourse.julialang.org/u/shipengcheng1230)\
**Post date:** [June 18, 2019, 8:40pm UTC](https://discourse.julialang.org/t/nested-arraypartition-cause-reduce-over-an-empty-collection/25424/1 "2019-06-18T20:40:40Z")

</div>

Hi, I was trying to simulate a physical system consisting of heterogeneous subpart sizes (i.e. arrays), so I use `RecursiveArrayTools`. Consider the following MWE:

```julia
julia> using DifferentialEquations

julia> function foo(du, u, p, t)
       end
foo (generic function with 1 method)

julia> u0 = ArrayPartition(rand(5), ArrayPartition(rand(5), rand(5)));

julia> prob = ODEProblem(foo, u0, (0.0, 1.0));

julia> integrator = init(prob, Tsit5())
ERROR: ArgumentError: reducing over an empty collection is not allowed
Stacktrace:
 [1] _empty_reduce_error() at ./reduce.jl:216

```

When `u0` is a nested `ArrayPartition`, it will pop this error up, which is in the call of `ODE_DEFAULT_NORM`. I am confused as to where is the empty array ever come from? Could anyone help me figure this out? Or if this solution construction is not recommended?

Thanks in advance!
