Skip to content

Commit 05c3c5d

Browse files
authored
Merge pull request #122 from JuliaParallel/anj/rand
Make drand work more generally
2 parents a233591 + d318df8 commit 05c3c5d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/darray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ dfill(v, d1::Integer, drest::Integer...) = dfill(v, convert(Dims, tuple(d1, dres
401401
Construct a distributed uniform random array.
402402
Trailing arguments are the same as those accepted by `DArray`.
403403
"""
404-
drand{T}(::Type{T}, dims::Dims, args...) = DArray(I->rand(T,map(length,I)), dims, args...)
405-
drand{T}(::Type{T}, d1::Integer, drest::Integer...) = drand(T, convert(Dims, tuple(d1, drest...)))
404+
drand(r, dims::Dims, args...) = DArray(I -> rand(r, map(length,I)), dims, args...)
405+
drand(r, d1::Integer, drest::Integer...) = drand(r, convert(Dims, tuple(d1, drest...)))
406406
drand(d1::Integer, drest::Integer...) = drand(Float64, convert(Dims, tuple(d1, drest...)))
407407
drand(d::Dims, args...) = drand(Float64, d, args...)
408408

test/darray.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,20 @@ t=@testset "test drand" begin
543543
close(A)
544544
end
545545

546+
@testset "1D drand, UnitRange" begin
547+
A = drand(1:10, 100)
548+
@test eltype(A) == Int
549+
@test size(A) == (100,)
550+
close(A)
551+
end
552+
553+
@testset "1D drand, Array" begin
554+
A = drand([-1,0,1], 100)
555+
@test eltype(A) == Int
556+
@test size(A) == (100,)
557+
close(A)
558+
end
559+
546560
@testset "2D drand, Dims constructor" begin
547561
A = drand((50,50))
548562
@test eltype(A) == Float64

0 commit comments

Comments
 (0)