Skip to content

Commit

Permalink
Merge pull request #39 from JuliaParallel/tanmaykm
Browse files Browse the repository at this point in the history
add getindex variants, and few minor syntax fixes
  • Loading branch information
tanmaykm committed Sep 19, 2015
2 parents 345e811 + 64a59a2 commit bc79efc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/DistributedArrays.jl
Expand Up @@ -52,7 +52,7 @@ type DArray{T,N,A} <: AbstractArray{T,N}
end

typealias SubDArray{T,N,D<:DArray} SubArray{T,N,D}
typealias SubOrDArray{T,N} Union(DArray{T,N}, SubDArray{T,N})
typealias SubOrDArray{T,N} Union{DArray{T,N}, SubDArray{T,N}}

## core constructors ##

Expand Down Expand Up @@ -419,7 +419,7 @@ Base.getindex(d::DArray, i::Int) = getindex_tuple(d, ind2sub(size(d), i))
Base.getindex(d::DArray, i::Int...) = getindex_tuple(d, i)

Base.getindex(d::DArray) = d[1]
Base.getindex(d::DArray, I::Union{Int,UnitRange{Int},Colon}...) = sub(d, I...)
Base.getindex(d::DArray, I::Union{Int,UnitRange{Int},Colon,Vector{Int},StepRange{Int,Int}}...) = sub(d, I...)

Base.copy!(dest::SubOrDArray, src::SubOrDArray) = begin
if !(dest.dims == src.dims &&
Expand Down Expand Up @@ -478,7 +478,7 @@ end

# to disambiguate
Base.setindex!(a::Array{Any}, d::SubOrDArray, i::Int) = Base.arrayset(a, d, i)
Base.setindex!(a::Array, d::SubOrDArray, I::Union(Int,UnitRange{Int})...) =
Base.setindex!(a::Array, d::SubOrDArray, I::Union{Int,UnitRange{Int}}...) =
setindex!(a, d, [isa(i, Int) ? (i:i) : i for i in I ]...)

Base.fill!(A::DArray, x) = begin
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Expand Up @@ -8,7 +8,7 @@ end
@assert nprocs() > 3
@assert nworkers() >= 3

@everywhere using DistributedArrays
using DistributedArrays
@everywhere blas_set_num_threads(1)
@everywhere srand(123 + myid())

Expand Down

0 comments on commit bc79efc

Please sign in to comment.