Skip to content

Commit 901b14e

Browse files
authored
Merge pull request #181 from JuliaParallel/vc/bc2
Small fixes to broadcast
2 parents 2ed228e + a489de4 commit 901b14e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/broadcast.jl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,18 @@ DArrayStyle(::Val{N}) where N = DArrayStyle{Broadcast.DefaultArrayStyle{N}}()
1616
BroadcastStyle(::Type{<:DArray{<:Any, N, A}}) where {N, A} = DArrayStyle(BroadcastStyle(A), Val(N))
1717

1818
# promotion rules
19+
# TODO: test this
1920
function BroadcastStyle(::DArrayStyle{AStyle}, ::DArrayStyle{BStyle}) where {AStyle, BStyle}
20-
DArrayStyle{BroadcastStyle(AStyle, BStyle)}()
21+
DArrayStyle(BroadcastStyle(AStyle, BStyle))
22+
end
23+
24+
function Broadcast.broadcasted(::DArrayStyle{Style}, f, args...) where Style
25+
inner = Broadcast.broadcasted(Style(), f, args...)
26+
if inner isa Broadcasted
27+
return Broadcasted{DArrayStyle{Style}}(inner.f, inner.args, inner.axes)
28+
else # eagerly evaluated
29+
return inner
30+
end
2131
end
2232

2333
# # deal with one layer deep lazy arrays
@@ -75,6 +85,10 @@ end
7585
return dest
7686
end
7787

88+
# Test
89+
# a = Array
90+
# a .= DArray(x,y)
91+
7892
@inline function Base.copy(bc::Broadcasted{<:DArrayStyle})
7993
dbc = bcdistribute(bc)
8094
# TODO: teach DArray about axes since this is wrong for OffsetArrays

0 commit comments

Comments
 (0)