Skip to content

Commit

Permalink
Merge pull request #71 from JuliaParallel/anj/setindex
Browse files Browse the repository at this point in the history
Fix setindex to work for more index types.
  • Loading branch information
andreasnoack committed Jun 3, 2016
2 parents 0215b9d + 997895d commit ec9ab98
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/DistributedArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ec9ab98

Please sign in to comment.