Skip to content

Commit d9814ff

Browse files
committed
remove rand!(::AbstractArray, ::AbstractArray) until JuliaLang#8246 is fixed
1 parent 91aa94f commit d9814ff

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

base/random.jl

+5-2
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,18 @@ rand(r::AbstractArray) = r[rand(randintgen(length(r)))]
204204

205205
# Arrays of random integers
206206

207-
function rand!(r::AbstractArray, A::AbstractArray)
207+
rand!(r::Range, A::AbstractArray) = rand!(r, A, ())
208+
209+
# TODO: this more general version is "disabled" until #8246 is resolved
210+
function rand!(r::AbstractArray, A::AbstractArray, ::())
208211
g = randintgen(length(r))
209212
for i = 1 : length(A)
210213
@inbounds A[i] = r[rand(g)]
211214
end
212215
return A
213216
end
214217

215-
rand{T}(r::AbstractArray{T}, dims::Dims) = rand!(r, Array(T, dims))
218+
rand{T}(r::AbstractArray{T}, dims::Dims) = rand!(r, Array(T, dims), ())
216219
rand(r::AbstractArray, dims::Int...) = rand(r, dims)
217220

218221

doc/stdlib/base.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -3964,9 +3964,9 @@ Random number generation in Julia uses the `Mersenne Twister library <http://www
39643964

39653965
Pick a random element or array of random elements from the indexable collection ``coll`` (for example, ``1:n`` or ``['x','y','z']``).
39663966

3967-
.. function:: rand!(coll, A)
3967+
.. function:: rand!(r, A)
39683968

3969-
Populate the array A with random values drawn uniformly from the indexable collection ``coll``.
3969+
Populate the array A with random values drawn uniformly from the range ``r``.
39703970

39713971
.. function:: randbool([dims...])
39723972

test/random.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ rand!(MersenneTwister(0), A)
2929
@test rand(0:3:1000) in 0:3:1000
3030
coll = {2, uint128(128), big(619), "string", 'c'}
3131
@test rand(coll) in coll
32-
@test issubset(rand!(coll, cell(10)), coll)
32+
@test issubset(rand(coll, 2, 3), coll)
3333

3434
# randn
3535
@test randn(MersenneTwister(42)) == -0.5560268761463861

0 commit comments

Comments
 (0)