From 997895d99215fee67f9f7be809e97cd2c9e44152 Mon Sep 17 00:00:00 2001 From: Andreas Noack Date: Tue, 31 May 2016 22:31:25 -0400 Subject: [PATCH] Fix setindex to work for more index types. --- src/DistributedArrays.jl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/DistributedArrays.jl b/src/DistributedArrays.jl index 5c5004d..233b69c 100644 --- a/src/DistributedArrays.jl +++ b/src/DistributedArrays.jl @@ -603,7 +603,8 @@ end # local copies are obtained by convert(Array, ) or assigning from # a SubDArray to a local Array. -Base.setindex!(a::Array, d::DArray, I::UnitRange{Int}...) = begin +function Base.setindex!(a::Array, d::DArray, + I::Union{UnitRange{Int},Colon,Vector{Int},StepRange{Int,Int}}...) n = length(I) @sync for i = 1:length(d.pids) K = d.indexes[i] @@ -612,7 +613,8 @@ Base.setindex!(a::Array, d::DArray, I::UnitRange{Int}...) = begin return a end -Base.setindex!(a::Array, s::SubDArray, I::UnitRange{Int}...) = begin +function Base.setindex!(a::Array, s::SubDArray, + I::Union{UnitRange{Int},Colon,Vector{Int},StepRange{Int,Int}}...) n = length(I) d = s.parent J = s.indexes @@ -641,9 +643,6 @@ Base.setindex!(a::Array, s::SubDArray, I::UnitRange{Int}...) = begin return a end -# to disambiguate -Base.setindex!(a::Array{Any}, d::SubOrDArray, i::Int) = Base.arrayset(a, d, i) - Base.fill!(A::DArray, x) = begin @sync for p in procs(A) @async remotecall_fetch((A,x)->(fill!(localpart(A), x); nothing), p, A, x)