Skip to content

Commit

Permalink
remove rand!(::AbstractArray, ::AbstractArray) until #8246 is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet committed Sep 16, 2014
1 parent 75aa207 commit e859850
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions base/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,18 @@ rand(r::AbstractArray) = r[rand(randintgen(length(r)))]

# Arrays of random integers

function rand!(r::AbstractArray, A::AbstractArray)
rand!(r::Range, A::AbstractArray) = rand!(r, A, ())

# TODO: this more general version is "disabled" until #8246 is resolved
function rand!(r::AbstractArray, A::AbstractArray, ::())
g = randintgen(length(r))
for i = 1 : length(A)
@inbounds A[i] = r[rand(g)]
end
return A
end

rand{T}(r::AbstractArray{T}, dims::Dims) = rand!(r, Array(T, dims))
rand{T}(r::AbstractArray{T}, dims::Dims) = rand!(r, Array(T, dims), ())
rand(r::AbstractArray, dims::Int...) = rand(r, dims)


Expand Down
4 changes: 2 additions & 2 deletions doc/stdlib/base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3952,9 +3952,9 @@ Random number generation in Julia uses the `Mersenne Twister library <http://www

Generate a random value drawn uniformly from the indexable collection ``coll`` (for example, ``1:n`` or ``['x','y','z']``). Optionally, generate a random array.

.. function:: rand!(coll, A)
.. function:: rand!(r, A)

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

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

Expand Down

0 comments on commit e859850

Please sign in to comment.