Skip to content

Commit 34551cf

Browse files
committed
change rand_function to randfun
1 parent 45947ec commit 34551cf

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/abstractsparsearray.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ spzeros(dims::Dims) = spzeros(Float64, dims)
6969
spzeros(::Type{T}, dims::Dims) where {T} = SparseArrayDOK{T}(undef, dims)
7070

7171
@doc """
72-
sprand([rng], [T::Type], dims; density::Real=0.5, rand_function::Function=rand) -> A::SparseArrayDOK{T}
72+
sprand([rng], [T::Type], dims; density::Real=0.5, randfun::Function=rand) -> A::SparseArrayDOK{T}
7373
7474
Create a random size `dims` sparse array in which the probability of any element being stored is independently given by `density`.
7575
The optional `rng` argument specifies a random number generator, see also `Random`.
7676
The optional `T` argument specifies the element type, which defaults to `Float64`.
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`.
77+
The optional `randfun` argument can be used to control the type of random elements, and should support
78+
the signature `randfun(rng, T, N)` to generate `N` entries of type `T`.
7979
8080
8181
See also [`sprand!`](@ref).
@@ -95,24 +95,24 @@ function sprand(rng::AbstractRNG, ::Type{T}, dims::Dims; kwargs...) where {T}
9595
end
9696

9797
@doc """
98-
sprand!([rng], A::AbstractArray; density::Real=0.5, rand_function::Function=rand) -> A
98+
sprand!([rng], A::AbstractArray; density::Real=0.5, randfun::Function=rand) -> A
9999
100100
Overwrite part of an array with random entries, where the probability of overwriting is independently given by `density`.
101101
The optional `rng` argument specifies a random number generator, see also `Random`.
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`.
102+
The optional `randfun` argument can be used to control the type of random elements, and should support
103+
the signature `randfun(rng, T, N)` to generate `N` entries of type `T`.
104104
105105
See also [`sprand`](@ref).
106106
""" sprand!
107107

108108
sprand!(A::AbstractArray; kwargs...) = sprand!(default_rng(), A; kwargs...)
109109
function sprand!(
110-
rng::AbstractRNG, A::AbstractArray; density::Real=0.5, rand_function::Function=Random.rand
110+
rng::AbstractRNG, A::AbstractArray; density::Real=0.5, randfun::Function=Random.rand
111111
)
112112
ArrayLayouts.zero!(A)
113113
rand_inds = Random.randsubseq(rng, eachindex(A), density)
114-
rand_entries = rand_function(rng, eltype(A), length(rand_inds))
115-
for (I, v) in zip(rand_inds, rand_entries)
114+
rand_entries = randfun(rng, eltype(A), length(rand_inds))
115+
@inbounds for (I, v) in zip(rand_inds, rand_entries)
116116
A[I] = v
117117
end
118118
end

0 commit comments

Comments
 (0)