Skip to content

Broadcasting with Float ArrayPartition #274

@HadrienNU

Description

@HadrienNU

I have an issue with broadcasting when the array partition is composed of Float64

julia> x = ArrayPartition(1.0,0.0);

julia> y=zero(x);

julia> y.=x
ERROR: MethodError: no method matching copyto!(::Float64, ::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{0}, Nothing, typeof(identity), Tuple{Float64}})
Closest candidates are:
  copyto!(::Any, ::ArrayLayouts.Lmul) at ~/.julia/packages/ArrayLayouts/A7uk9/src/lmul.jl:75
  copyto!(::Any, ::ArrayLayouts.Rmul) at ~/.julia/packages/ArrayLayouts/A7uk9/src/lmul.jl:77
  copyto!(::Any, ::ArrayLayouts.Mul) at ~/.julia/packages/ArrayLayouts/A7uk9/src/mul.jl:127
  ...
Stacktrace:
 [1] f
   @ ~/.julia/packages/RecursiveArrayTools/w8ctF/src/array_partition.jl:372 [inlined]
 [2] ntuple
   @ ./ntuple.jl:49 [inlined]
 [3] copyto!
   @ ~/.julia/packages/RecursiveArrayTools/w8ctF/src/array_partition.jl:374 [inlined]
 [4] materialize!
   @ ./broadcast.jl:871 [inlined]
 [5] materialize!(dest::ArrayPartition{Float64, Tuple{Float64, Float64}}, bc::Base.Broadcast.Broadcasted{RecursiveArrayTools.ArrayPartitionStyle{Base.Broadcast.DefaultArrayStyle{0}}, Nothing, typeof(identity), Tuple{ArrayPartition{Float64, Tuple{Float64, Float64}}}})
   @ Base.Broadcast ./broadcast.jl:868
 [6] top-level scope
   @ REPL[39]:1

Indeed, when testing for typeof(x) <: AbstractArray it returns true and some codes assume that dot syntax is fine.
In my case, when trying to do ensemble simulation with ArrayPartition. The analysis at https://github.com/SciML/SciMLBase.jl/blob/master/src/ensemble/ensemble_analysis.jl#L209 assumes it can safely use dot syntax and then raise the error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions