@@ -69,12 +69,14 @@ spzeros(dims::Dims) = spzeros(Float64, dims)
6969spzeros (:: Type{T} , dims:: Dims ) where  {T} =  SparseArrayDOK {T} (undef, dims)
7070
7171@doc  """ 
72-     sprand([rng], [T::Type], dims; density::Real=0.5, rfn ::Function=rand) -> A::SparseArrayDOK{T} 
72+     sprand([rng], [T::Type], dims; density::Real=0.5, rand_function ::Function=rand) -> A::SparseArrayDOK{T} 
7373
7474Create a random size `dims` sparse array in which the probability of any element being stored is independently given by `density`. 
7575The optional `rng` argument specifies a random number generator, see also `Random`. 
7676The optional `T` argument specifies the element type, which defaults to `Float64`. 
77- The optional `rfn` argument can be used to control the type of random elements. 
77+ The optional `rand_function` argument can be used to control the type of random elements, and should support 
78+ the signature `rand_function(rng, T, N)` to generate `N` entries of type `T`. 
79+ 
7880
7981See also [`sprand!`](@ref). 
8082"""  
@@ -93,22 +95,23 @@ function sprand(rng::AbstractRNG, ::Type{T}, dims::Dims; kwargs...) where {T}
9395end 
9496
9597@doc  """ 
96-     sprand!([rng], A::AbstractArray; density::Real=0.5, rfn ::Function=rand) -> A 
98+     sprand!([rng], A::AbstractArray; density::Real=0.5, rand_function ::Function=rand) -> A 
9799
98100Overwrite part of an array with random entries, where the probability of overwriting is independently given by `density`. 
99101The optional `rng` argument specifies a random number generator, see also `Random`. 
100- The optional `rfn` argument can be used to control the type of random elements. 
102+ The optional `rand_function` argument can be used to control the type of random elements, and should support 
103+ the signature `rand_function(rng, T, N)` to generate `N` entries of type `T`. 
101104
102105See also [`sprand`](@ref). 
103106"""  
104107
105108sprand! (A:: AbstractArray ; kwargs... ) =  sprand! (default_rng (), A; kwargs... )
106109function  sprand! (
107-   rng:: AbstractRNG , A:: AbstractArray ; density:: Real = 0.5 , rfn :: Function = Random. rand
110+   rng:: AbstractRNG , A:: AbstractArray ; density:: Real = 0.5 , rand_function :: Function = Random. rand
108111)
109112  ArrayLayouts. zero! (A)
110113  rand_inds =  Random. randsubseq (rng, eachindex (A), density)
111-   rand_entries =  rfn (rng, eltype (A), length (rand_inds))
114+   rand_entries =  rand_function (rng, eltype (A), length (rand_inds))
112115  for  (I, v) in  zip (rand_inds, rand_entries)
113116    A[I] =  v
114117  end 
0 commit comments