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

doc: add missing docstrings to SparseArrays #31286

Merged
merged 1 commit into from
Apr 3, 2019
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
4 changes: 4 additions & 0 deletions stdlib/SparseArrays/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ section of the standard library reference.
# [Sparse Arrays](@id stdlib-sparse-arrays)

```@docs
SparseArrays.AbstractSparseArray
SparseArrays.AbstractSparseVector
SparseArrays.AbstractSparseMatrix
SparseArrays.SparseVector
SparseArrays.SparseMatrixCSC
SparseArrays.sparse
Expand All @@ -217,6 +220,7 @@ SparseArrays.sprandn
SparseArrays.nonzeros
SparseArrays.rowvals
SparseArrays.nzrange
SparseArrays.droptol!
SparseArrays.dropzeros!
SparseArrays.dropzeros
SparseArrays.permute
Expand Down
18 changes: 18 additions & 0 deletions stdlib/SparseArrays/src/abstractsparse.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license
"""
AbstractSparseArray{Tv,Ti,N}

Supertype for `N`-dimensional sparse arrays (or array-like types) with elements
of type `Tv` and index type `Ti`. [`SparseMatrixCSC`](@ref), [`SparseVector`](@ref)
and `SuiteSparse.CHOLMOD.Sparse` are subtypes of this.
"""
abstract type AbstractSparseArray{Tv,Ti,N} <: AbstractArray{Tv,N} end

"""
AbstractSparseVector{Tv,Ti}

Supertype for one-dimensional sparse arrays (or array-like types) with elements
of type `Tv` and index type `Ti`. Alias for `AbstractSparseArray{Tv,Ti,1}``.
"""
const AbstractSparseVector{Tv,Ti} = AbstractSparseArray{Tv,Ti,1}
"""
AbstractSparseMatrix{Tv,Ti}

Supertype for two-dimensional sparse arrays (or array-like types) with elements
of type `Tv` and index type `Ti`. Alias for `AbstractSparseArray{Tv,Ti,2}`.
"""
const AbstractSparseMatrix{Tv,Ti} = AbstractSparseArray{Tv,Ti,2}

"""
Expand Down
7 changes: 7 additions & 0 deletions stdlib/SparseArrays/src/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,13 @@ tril!(A::SparseMatrixCSC, k::Integer = 0, trim::Bool = true) =
triu!(A::SparseMatrixCSC, k::Integer = 0, trim::Bool = true) =
fkeep!(A, (i, j, x) -> j >= i + k, trim)

"""
droptol!(A::SparseMatrixCSC, tol; trim::Bool = true)

Removes stored values from `A` whose absolute value is (strictly) larger than `tol`,
optionally trimming resulting excess space from `A.rowval` and `A.nzval` when `trim`
is `true`.
"""
droptol!(A::SparseMatrixCSC, tol; trim::Bool = true) =
fkeep!(A, (i, j, x) -> abs(x) > tol, trim)

Expand Down
7 changes: 7 additions & 0 deletions stdlib/SparseArrays/src/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1911,6 +1911,13 @@ function fkeep!(x::SparseVector, f, trim::Bool = true)
x
end

"""
droptol!(x::SparseVector, tol; trim::Bool = true)
Removes stored values from `x` whose absolute value is (strictly) larger than `tol`,
optionally trimming resulting excess space from `A.rowval` and `A.nzval` when `trim`
is `true`.
"""
droptol!(x::SparseVector, tol; trim::Bool = true) = fkeep!(x, (i, x) -> abs(x) > tol, trim)

"""
Expand Down