@@ -233,14 +233,19 @@ Base.show(io::IO, m::MIME"text/plain", A::ArrayPartition) = show(io, m, A.x)
233233
234234# # broadcasting
235235
236- Base. Broadcast. _containertype (:: Type{<:ArrayPartition} ) = ArrayPartition
237- Base. Broadcast. promote_containertype (:: Type{ArrayPartition} , :: Type ) = ArrayPartition
238- Base. Broadcast. promote_containertype (:: Type , :: Type{ArrayPartition} ) = ArrayPartition
239- Base. Broadcast. promote_containertype (:: Type{ArrayPartition} , :: Type{ArrayPartition} ) = ArrayPartition
240- Base. Broadcast. promote_containertype (:: Type{ArrayPartition} , :: Type{Array} ) = ArrayPartition
241- Base. Broadcast. promote_containertype (:: Type{Array} , :: Type{ArrayPartition} ) = ArrayPartition
242-
243- @generated function Base. Broadcast. broadcast_c (f, :: Type{ArrayPartition} , as... )
236+ struct APStyle <: Broadcast.BroadcastStyle end
237+ Base. BroadcastStyle (:: Type{<:ArrayPartition} ) = Broadcast. ArrayStyle {ArrayPartition} ()
238+ Base. BroadcastStyle (:: Broadcast.ArrayStyle{ArrayPartition} ,:: Broadcast.ArrayStyle ) = Broadcast. Style {ArrayPartition} ()
239+ Base. BroadcastStyle (:: Broadcast.ArrayStyle ,:: Broadcast.ArrayStyle{ArrayPartition} ) = Broadcast. Style {ArrayPartition} ()
240+ Base. similar (bc:: Broadcast.Broadcasted{Broadcast.ArrayStyle{ArrayPartition}} ,:: Type{ElType} ) where ElType = similar (bc)
241+
242+ function Base. copy (bc:: Broadcast.Broadcasted{Broadcast.ArrayStyle{ArrayPartition}} )
243+ ret = Broadcast. flatten (bc)
244+ __broadcast (ret. f,ret. args... )
245+ end
246+
247+ @generated function __broadcast (f,as... )
248+
244249 # common number of partitions
245250 N = npartitions (as... )
246251
@@ -249,12 +254,15 @@ Base.Broadcast.promote_containertype(::Type{Array}, ::Type{ArrayPartition}) = Ar
249254 # index partitions
250255 $ ((as[d] <: ArrayPartition ? :(as[$ d]. x[i]) : :(as[$ d])
251256 for d in 1 : length (as)). .. )))
252-
253257 build_arraypartition (N, expr)
254258end
255259
256- @generated function Base. Broadcast. broadcast_c! (f, :: Type{ArrayPartition} , :: Type ,
257- dest:: ArrayPartition , as... )
260+ function Base. copyto! (dest:: AbstractArray ,bc:: Broadcast.Broadcasted{Broadcast.ArrayStyle{ArrayPartition}} )
261+ ret = Broadcast. flatten (bc)
262+ __broadcast! (ret. f,dest,ret. args... )
263+ end
264+
265+ @generated function __broadcast! (f, dest, as... )
258266 # common number of partitions
259267 N = npartitions (dest, as... )
260268
0 commit comments