Skip to content

Commit 8440661

Browse files
committed
change spzeros, sprand and sprand! to sparsezeros, sparserand and sparserand!
1 parent 34551cf commit 8440661

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

src/SparseArraysBase.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ export SparseArrayDOK,
1212
storedlength,
1313
storedpairs,
1414
storedvalues,
15-
spzeros,
16-
sprand,
17-
sprand!
15+
sparsezeros,
16+
sparserand,
17+
sparserand!
1818

1919
include("abstractsparsearrayinterface.jl")
2020
include("sparsearrayinterface.jl")

src/abstractsparsearray.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ eachstoredindex(a::ReplacedUnstoredSparseArray) = eachstoredindex(parent(a))
5959
using Random: Random, AbstractRNG, default_rng
6060

6161
@doc """
62-
spzeros([T::Type], dims) -> A::SparseArrayDOK{T}
62+
sparsezeros([T::Type], dims) -> A::SparseArrayDOK{T}
6363
6464
Create an empty size `dims` sparse array.
6565
The optional `T` argument specifies the element type, which defaults to `Float64`.
66-
""" spzeros
66+
""" sparsezeros
6767

68-
spzeros(dims::Dims) = spzeros(Float64, dims)
69-
spzeros(::Type{T}, dims::Dims) where {T} = SparseArrayDOK{T}(undef, dims)
68+
sparsezeros(dims::Dims) = sparsezeros(Float64, dims)
69+
sparsezeros(::Type{T}, dims::Dims) where {T} = SparseArrayDOK{T}(undef, dims)
7070

7171
@doc """
72-
sprand([rng], [T::Type], dims; density::Real=0.5, randfun::Function=rand) -> A::SparseArrayDOK{T}
72+
sparserand([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`.
@@ -78,35 +78,35 @@ The optional `randfun` argument can be used to control the type of random elemen
7878
the signature `randfun(rng, T, N)` to generate `N` entries of type `T`.
7979
8080
81-
See also [`sprand!`](@ref).
82-
""" sprand
81+
See also [`sparserand!`](@ref).
82+
""" sparserand
8383

84-
function sprand(::Type{T}, dims::Dims; kwargs...) where {T}
85-
return sprand(default_rng(), T, dims; kwargs...)
84+
function sparserand(::Type{T}, dims::Dims; kwargs...) where {T}
85+
return sparserand(default_rng(), T, dims; kwargs...)
8686
end
87-
sprand(dims::Dims; kwargs...) = sprand(default_rng(), Float64, dims; kwargs...)
88-
function sprand(rng::AbstractRNG, dims::Dims; kwargs...)
89-
return sprand(rng, Float64, dims; kwargs...)
87+
sparserand(dims::Dims; kwargs...) = sparserand(default_rng(), Float64, dims; kwargs...)
88+
function sparserand(rng::AbstractRNG, dims::Dims; kwargs...)
89+
return sparserand(rng, Float64, dims; kwargs...)
9090
end
91-
function sprand(rng::AbstractRNG, ::Type{T}, dims::Dims; kwargs...) where {T}
91+
function sparserand(rng::AbstractRNG, ::Type{T}, dims::Dims; kwargs...) where {T}
9292
A = SparseArrayDOK{T}(undef, dims)
93-
sprand!(rng, A; kwargs...)
93+
sparserand!(rng, A; kwargs...)
9494
return A
9595
end
9696

9797
@doc """
98-
sprand!([rng], A::AbstractArray; density::Real=0.5, randfun::Function=rand) -> A
98+
sparserand!([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`.
102102
The optional `randfun` argument can be used to control the type of random elements, and should support
103103
the signature `randfun(rng, T, N)` to generate `N` entries of type `T`.
104104
105-
See also [`sprand`](@ref).
106-
""" sprand!
105+
See also [`sparserand`](@ref).
106+
""" sparserand!
107107

108-
sprand!(A::AbstractArray; kwargs...) = sprand!(default_rng(), A; kwargs...)
109-
function sprand!(
108+
sparserand!(A::AbstractArray; kwargs...) = sparserand!(default_rng(), A; kwargs...)
109+
function sparserand!(
110110
rng::AbstractRNG, A::AbstractArray; density::Real=0.5, randfun::Function=Random.rand
111111
)
112112
ArrayLayouts.zero!(A)

test/test_exports.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ using Test: @test, @testset
1515
:storedlength,
1616
:storedpairs,
1717
:storedvalues,
18-
:spzeros,
19-
:sprand,
20-
:sprand!,
18+
:sparsezeros,
19+
:sparserand,
20+
:sparserand!,
2121
]
2222
@test issetequal(names(SparseArraysBase), exports)
2323
end

test/test_linalg.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using SparseArraysBase: sprand
1+
using SparseArraysBase: sparserand
22
using LinearAlgebra: mul!
33
using StableRNGs: StableRNG
44

@@ -11,9 +11,9 @@ const rng = StableRNG(123)
1111
szC = (szA[1], szB[2])
1212

1313
for density in 0.0:0.25:1
14-
C = sprand(rng, T, szC; density)
15-
A = sprand(rng, T, szA; density)
16-
B = sprand(rng, T, szB; density)
14+
C = sparserand(rng, T, szC; density)
15+
A = sparserand(rng, T, szA; density)
16+
B = sparserand(rng, T, szB; density)
1717

1818
check1 = mul!(Array(C), Array(A), Array(B))
1919
@test mul!(copy(C), A, B) check1

0 commit comments

Comments
 (0)