Skip to content

Commit ec9ab98

Browse files
committed
Merge pull request #71 from JuliaParallel/anj/setindex
Fix setindex to work for more index types.
2 parents 0215b9d + 997895d commit ec9ab98

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/DistributedArrays.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,8 @@ end
603603
# local copies are obtained by convert(Array, ) or assigning from
604604
# a SubDArray to a local Array.
605605

606-
Base.setindex!(a::Array, d::DArray, I::UnitRange{Int}...) = begin
606+
function Base.setindex!(a::Array, d::DArray,
607+
I::Union{UnitRange{Int},Colon,Vector{Int},StepRange{Int,Int}}...)
607608
n = length(I)
608609
@sync for i = 1:length(d.pids)
609610
K = d.indexes[i]
@@ -612,7 +613,8 @@ Base.setindex!(a::Array, d::DArray, I::UnitRange{Int}...) = begin
612613
return a
613614
end
614615

615-
Base.setindex!(a::Array, s::SubDArray, I::UnitRange{Int}...) = begin
616+
function Base.setindex!(a::Array, s::SubDArray,
617+
I::Union{UnitRange{Int},Colon,Vector{Int},StepRange{Int,Int}}...)
616618
n = length(I)
617619
d = s.parent
618620
J = s.indexes
@@ -641,9 +643,6 @@ Base.setindex!(a::Array, s::SubDArray, I::UnitRange{Int}...) = begin
641643
return a
642644
end
643645

644-
# to disambiguate
645-
Base.setindex!(a::Array{Any}, d::SubOrDArray, i::Int) = Base.arrayset(a, d, i)
646-
647646
Base.fill!(A::DArray, x) = begin
648647
@sync for p in procs(A)
649648
@async remotecall_fetch((A,x)->(fill!(localpart(A), x); nothing), p, A, x)

0 commit comments

Comments
 (0)