|
34 | 34 | =#
|
35 | 35 |
|
36 | 36 | @inline function Base.copy(bc::Broadcast.Broadcasted{Broadcast.ArrayStyle{AMSA}})
|
| 37 | + first_amsa = find_amsa(bc) |
| 38 | + out = deepcopy(first_amsa) |
| 39 | + copyto!(out,bc) |
| 40 | + out |
| 41 | + #= |
37 | 42 | N = nnodes(bc)
|
38 | 43 | @inline function f(i)
|
39 | 44 | copy(unpack(bc, i))
|
40 | 45 | end
|
41 | 46 | first_amsa = find_amsa(bc)
|
42 |
| - construct(first_amsa, map(f,N), f(nothing)) |
| 47 | + if length(fieldnames(typeof(first_amsa))) == 1 |
| 48 | + construct(parameterless_type(first_amsa), map(f,N), f(nothing)) |
| 49 | + else |
| 50 | + out = deepcopy(first_amsa) |
| 51 | + copyto!(out,bc) |
| 52 | + return out |
| 53 | + end |
| 54 | + =# |
43 | 55 | end
|
44 | 56 |
|
45 | 57 | @inline function Base.copy(bc::Broadcast.Broadcasted{Broadcast.ArrayStyle{AbstractMultiScaleArrayLeaf}})
|
46 |
| - @show bc |
| 58 | + first_amsa = find_amsa(bc) |
| 59 | + out = deepcopy(first_amsa) |
| 60 | + copyto!(out,bc) |
| 61 | + out |
| 62 | + #= |
47 | 63 | @inline function f(i)
|
48 | 64 | copy(unpack(bc, i))
|
49 | 65 | end
|
50 |
| - first_amsa = find_amsa(bc) |
51 |
| - @show first_amsa |
52 |
| - construct(first_amsa, f(nothing)) |
| 66 | +
|
| 67 | + if length(fieldnames(typeof(first_amsa))) == 1 |
| 68 | + return construct(parameterless_type(first_amsa), f(nothing)) |
| 69 | + else |
| 70 | +
|
| 71 | + return out |
| 72 | + end |
| 73 | + =# |
53 | 74 | end
|
54 | 75 |
|
55 | 76 | @inline function Base.copyto!(dest::AMSA, bc::Broadcast.Broadcasted{Nothing})
|
|
60 | 81 | copyto!(dest.values,unpack(bc, nothing))
|
61 | 82 | end
|
62 | 83 |
|
63 |
| -@inline function Base.copyto!(dest::AbstractMultiScaleArrayLeaf, bc::Broadcast.Broadcasted) |
| 84 | +@inline function Base.copyto!(dest::AbstractMultiScaleArrayLeaf, bc::Broadcast.Broadcasted{Nothing}) |
64 | 85 | copyto!(dest.values,unpack(bc,nothing))
|
65 | 86 | end
|
66 | 87 |
|
67 | 88 | # drop axes because it is easier to recompute
|
68 |
| -@inline unpack(bc::Broadcast.Broadcasted{Style}, i) where Style = Broadcast.Broadcasted{Style}(bc.f, unpack_args(i, bc.args)) |
69 |
| -@inline unpack(bc::Broadcast.Broadcasted{Broadcast.ArrayStyle{AMSA}}, i) = Broadcast.Broadcasted{Broadcast.ArrayStyle{AMSA}}(bc.f, unpack_args(i, bc.args)) |
| 89 | +@inline unpack(bc::Broadcast.Broadcasted, i) = Broadcast.Broadcasted(bc.f, unpack_args(i, bc.args)) |
70 | 90 | unpack(x,::Any) = x
|
71 | 91 | unpack(x::AMSA, i) = x.nodes[i]
|
72 | 92 | unpack(x::AMSA, ::Nothing) = x.values
|
|
0 commit comments