Skip to content

Commit a80e80a

Browse files
committed
remove Random.defaultRNG()
This function is an artifact of an intermediate state of PR #24874, but is not needed anymore.
1 parent 625923f commit a80e80a

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

stdlib/Random/src/Random.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@ export srand,
2727
randperm, randperm!,
2828
randcycle, randcycle!,
2929
AbstractRNG, MersenneTwister, RandomDevice,
30-
defaultRNG, randjump
30+
randjump
3131

3232

3333
## general definitions
3434

3535
abstract type AbstractRNG end
3636

37-
defaultRNG() = GLOBAL_RNG
38-
3937

4038
### integers
4139

stdlib/SparseArrays/src/SparseArrays.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import Base: @get!, acos, acosd, acot, acotd, acsch, asech, asin, asind, asinh,
3030
rotl90, rotr90, round, setindex!, similar, size, transpose,
3131
vec, permute!, map, map!, Array
3232

33-
using Random: defaultRNG, AbstractRNG, randsubseq, randsubseq!
33+
using Random: GLOBAL_RNG, AbstractRNG, randsubseq, randsubseq!
3434

3535
export AbstractSparseArray, AbstractSparseMatrix, AbstractSparseVector,
3636
SparseMatrixCSC, SparseVector, blkdiag, droptol!, dropzeros!, dropzeros,

stdlib/SparseArrays/src/sparsematrix.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,18 +1417,18 @@ function sprand(m::Integer, n::Integer, density::AbstractFloat,
14171417
N == 0 && return spzeros(T,m,n)
14181418
N == 1 && return rand() <= density ? sparse([1], [1], rfn(1)) : spzeros(T,1,1)
14191419

1420-
I,J = sprand_IJ(defaultRNG(), m, n, density)
1420+
I,J = sprand_IJ(GLOBAL_RNG, m, n, density)
14211421
sparse_IJ_sorted!(I, J, rfn(length(I)), m, n, +) # it will never need to combine
14221422
end
14231423

14241424
truebools(r::AbstractRNG, n::Integer) = fill(true, n)
14251425

1426-
sprand(m::Integer, n::Integer, density::AbstractFloat) = sprand(defaultRNG(),m,n,density)
1426+
sprand(m::Integer, n::Integer, density::AbstractFloat) = sprand(GLOBAL_RNG,m,n,density)
14271427

14281428
sprand(r::AbstractRNG, m::Integer, n::Integer, density::AbstractFloat) = sprand(r,m,n,density,rand,Float64)
14291429
sprand(r::AbstractRNG, ::Type{T}, m::Integer, n::Integer, density::AbstractFloat) where {T} = sprand(r,m,n,density,(r, i) -> rand(r, T, i), T)
14301430
sprand(r::AbstractRNG, ::Type{Bool}, m::Integer, n::Integer, density::AbstractFloat) = sprand(r,m,n,density, truebools, Bool)
1431-
sprand(::Type{T}, m::Integer, n::Integer, density::AbstractFloat) where {T} = sprand(defaultRNG(), T, m, n, density)
1431+
sprand(::Type{T}, m::Integer, n::Integer, density::AbstractFloat) where {T} = sprand(GLOBAL_RNG, T, m, n, density)
14321432

14331433
"""
14341434
sprandn([rng], m[,n],p::AbstractFloat)
@@ -1450,7 +1450,7 @@ julia> sprandn(rng, 2, 2, 0.75)
14501450
```
14511451
"""
14521452
sprandn(r::AbstractRNG, m::Integer, n::Integer, density::AbstractFloat) = sprand(r,m,n,density,randn,Float64)
1453-
sprandn(m::Integer, n::Integer, density::AbstractFloat) = sprandn(defaultRNG(),m,n,density)
1453+
sprandn(m::Integer, n::Integer, density::AbstractFloat) = sprandn(GLOBAL_RNG,m,n,density)
14541454

14551455
LinearAlgebra.fillstored!(S::SparseMatrixCSC, x) = (fill!(view(S.nzval, 1:(S.colptr[S.n + 1] - 1)), x); S)
14561456

stdlib/SparseArrays/src/sparsevector.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,28 +472,28 @@ copyto!(A::SparseMatrixCSC, B::SparseVector{TvB,TiB}) where {TvB,TiB} =
472472

473473

474474
### Rand Construction
475-
sprand(n::Integer, p::AbstractFloat, rfn::Function, ::Type{T}) where {T} = sprand(defaultRNG(), n, p, rfn, T)
475+
sprand(n::Integer, p::AbstractFloat, rfn::Function, ::Type{T}) where {T} = sprand(GLOBAL_RNG, n, p, rfn, T)
476476
function sprand(r::AbstractRNG, n::Integer, p::AbstractFloat, rfn::Function, ::Type{T}) where T
477477
I = randsubseq(r, 1:convert(Int, n), p)
478478
V = rfn(r, T, length(I))
479479
SparseVector(n, I, V)
480480
end
481481

482-
sprand(n::Integer, p::AbstractFloat, rfn::Function) = sprand(defaultRNG(), n, p, rfn)
482+
sprand(n::Integer, p::AbstractFloat, rfn::Function) = sprand(GLOBAL_RNG, n, p, rfn)
483483
function sprand(r::AbstractRNG, n::Integer, p::AbstractFloat, rfn::Function)
484484
I = randsubseq(r, 1:convert(Int, n), p)
485485
V = rfn(r, length(I))
486486
SparseVector(n, I, V)
487487
end
488488

489-
sprand(n::Integer, p::AbstractFloat) = sprand(defaultRNG(), n, p, rand)
489+
sprand(n::Integer, p::AbstractFloat) = sprand(GLOBAL_RNG, n, p, rand)
490490

491491
sprand(r::AbstractRNG, n::Integer, p::AbstractFloat) = sprand(r, n, p, rand)
492492
sprand(r::AbstractRNG, ::Type{T}, n::Integer, p::AbstractFloat) where {T} = sprand(r, n, p, (r, i) -> rand(r, T, i))
493493
sprand(r::AbstractRNG, ::Type{Bool}, n::Integer, p::AbstractFloat) = sprand(r, n, p, truebools)
494-
sprand(::Type{T}, n::Integer, p::AbstractFloat) where {T} = sprand(defaultRNG(), T, n, p)
494+
sprand(::Type{T}, n::Integer, p::AbstractFloat) where {T} = sprand(GLOBAL_RNG, T, n, p)
495495

496-
sprandn(n::Integer, p::AbstractFloat) = sprand(defaultRNG(), n, p, randn)
496+
sprandn(n::Integer, p::AbstractFloat) = sprand(GLOBAL_RNG, n, p, randn)
497497
sprandn(r::AbstractRNG, n::Integer, p::AbstractFloat) = sprand(r, n, p, randn)
498498

499499
## Indexing into Matrices can return SparseVectors

0 commit comments

Comments
 (0)