Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate rand(::Tuple) #25429

Merged
merged 1 commit into from
Jan 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,9 @@ Deprecated or removed
have been deprecated. Subtypes of `AbstractArray` that implement the newly introduced strided
array interface should define their own `strides` method ([#25321]).

* `rand(t::Tuple{Vararg{Int}})` is deprecated in favor of `rand(Float64, t)` or `rand(t...)`;
`rand(::Tuple)` will have another meaning in the future ([#25429], [#25278]).


Command-line option changes
---------------------------
Expand Down
9 changes: 4 additions & 5 deletions stdlib/Random/src/Random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,8 @@ function rand!(rng::AbstractRNG, A::AbstractArray{T}, sp::Sampler) where T
A
end

rand(r::AbstractRNG, dims::Dims) = rand(r, Float64, dims)
rand( dims::Dims) = rand(GLOBAL_RNG, dims)
rand(r::AbstractRNG, dims::Integer...) = rand(r, Dims(dims))
rand( dims::Integer...) = rand(Dims(dims))
rand(r::AbstractRNG, dims::Integer...) = rand(r, Float64, Dims(dims))
rand( dims::Integer...) = rand(Float64, Dims(dims))

rand(r::AbstractRNG, X, dims::Dims) = rand!(r, Array{eltype(X)}(uninitialized, dims), X)
rand( X, dims::Dims) = rand(GLOBAL_RNG, X, dims)
Expand Down Expand Up @@ -273,7 +271,8 @@ Pick a random element or array of random elements from the set of values specifi
integers (this is not applicable to [`BigInt`](@ref)), and to ``[0, 1)`` for floating
point numbers;

`S` defaults to [`Float64`](@ref).
`S` defaults to [`Float64`](@ref)
(except when `dims` is a tuple of integers, in which case `S` must be specified).

# Examples
```julia-repl
Expand Down
4 changes: 4 additions & 0 deletions stdlib/Random/src/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ end

@deprecate convert(::Type{UInt128}, u::UUID) UInt128(u)
@deprecate convert(::Type{UUID}, s::AbstractString) UUID(s)

# PR #25429
@deprecate rand(r::AbstractRNG, dims::Dims) rand(r, Float64, dims)
@deprecate rand( dims::Dims) rand(Float64, dims)
1 change: 0 additions & 1 deletion stdlib/Random/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ for rng in ([], [MersenneTwister(0)], [RandomDevice()])
f(rng..., 5) ::Vector{Float64}
f(rng..., 2, 3) ::Array{Float64, 2}
f(rng..., b2, u3) ::Array{Float64, 2}
f(rng..., (2, 3)) ::Array{Float64, 2}
for T in functypes[f]
a0 = f(rng..., T) ::T
a1 = f(rng..., T, 5) ::Vector{T}
Expand Down
2 changes: 1 addition & 1 deletion stdlib/SharedArrays/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ copyto!(s, d)
s = SharedArrays.shmem_rand(dims)
copyto!(s, sdata(d))
@test s == d
a = rand(dims)
a = rand(Float64, dims)
@test sdata(a) == a

d = SharedArray{Int}(dims, init = D->fill!(D.loc_subarr_1d, myid()))
Expand Down