Skip to content

Commit 1748989

Browse files
authored
Move fkeep! docstring to the right function (#503)
* Move `fkeep!` docstring to the right function * Add docstring test
1 parent 1aa6431 commit 1748989

File tree

2 files changed

+35
-29
lines changed

2 files changed

+35
-29
lines changed

src/sparsematrix.jl

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,35 +1763,6 @@ end
17631763

17641764
## fkeep! and children tril!, triu!, droptol!, dropzeros[!]
17651765

1766-
"""
1767-
fkeep!(f, A::AbstractSparseArray)
1768-
1769-
Keep elements of `A` for which test `f` returns `true`. `f`'s signature should be
1770-
1771-
f(i::Integer, [j::Integer,] x) -> Bool
1772-
1773-
where `i` and `j` are an element's row and column indices and `x` is the element's
1774-
value. This method makes a single sweep
1775-
through `A`, requiring `O(size(A, 2), nnz(A))`-time for matrices and `O(nnz(A))`-time for vectors
1776-
and no space beyond that passed in.
1777-
1778-
# Examples
1779-
```jldoctest
1780-
julia> A = sparse(Diagonal([1, 2, 3, 4]))
1781-
4×4 SparseMatrixCSC{Int64, Int64} with 4 stored entries:
1782-
1 ⋅ ⋅ ⋅
1783-
⋅ 2 ⋅ ⋅
1784-
⋅ ⋅ 3 ⋅
1785-
⋅ ⋅ ⋅ 4
1786-
1787-
julia> SparseArrays.fkeep!((i, j, v) -> isodd(v), A)
1788-
4×4 SparseMatrixCSC{Int64, Int64} with 2 stored entries:
1789-
1 ⋅ ⋅ ⋅
1790-
⋅ ⋅ ⋅ ⋅
1791-
⋅ ⋅ 3 ⋅
1792-
⋅ ⋅ ⋅ ⋅
1793-
```
1794-
"""
17951766
function _fkeep!(f::F, A::AbstractSparseMatrixCSC) where F<:Function
17961767
An = size(A, 2)
17971768
Acolptr = getcolptr(A)
@@ -1839,6 +1810,35 @@ function _fkeep!_fixed(f::F, A::AbstractSparseMatrixCSC) where F<:Function
18391810
return A
18401811
end
18411812

1813+
"""
1814+
fkeep!(f, A::AbstractSparseArray)
1815+
1816+
Keep elements of `A` for which test `f` returns `true`. `f`'s signature should be
1817+
1818+
f(i::Integer, [j::Integer,] x) -> Bool
1819+
1820+
where `i` and `j` are an element's row and column indices and `x` is the element's
1821+
value. This method makes a single sweep
1822+
through `A`, requiring `O(size(A, 2), nnz(A))`-time for matrices and `O(nnz(A))`-time for vectors
1823+
and no space beyond that passed in.
1824+
1825+
# Examples
1826+
```jldoctest
1827+
julia> A = sparse(Diagonal([1, 2, 3, 4]))
1828+
4×4 SparseMatrixCSC{Int64, Int64} with 4 stored entries:
1829+
1 ⋅ ⋅ ⋅
1830+
⋅ 2 ⋅ ⋅
1831+
⋅ ⋅ 3 ⋅
1832+
⋅ ⋅ ⋅ 4
1833+
1834+
julia> SparseArrays.fkeep!((i, j, v) -> isodd(v), A)
1835+
4×4 SparseMatrixCSC{Int64, Int64} with 2 stored entries:
1836+
1 ⋅ ⋅ ⋅
1837+
⋅ ⋅ ⋅ ⋅
1838+
⋅ ⋅ 3 ⋅
1839+
⋅ ⋅ ⋅ ⋅
1840+
```
1841+
"""
18421842
fkeep!(f::F, A::AbstractSparseMatrixCSC) where F<:Function = _is_fixed(A) ? _fkeep!_fixed(f, A) : _fkeep!(f, A)
18431843

18441844
# deprecated syntax

test/issues.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,12 @@ end
658658
@test s[3] === -0.0
659659
end
660660

661+
if isdefined(Docs, :undocumented_names) # new in Julia 1.11
662+
@testset "docstrings (issue julia#52725)" begin
663+
@test isempty(Docs.undocumented_names(SparseArrays))
664+
end
665+
end
666+
661667
# As part of the migration of SparseArrays.jl into its own repo,
662668
# these tests have been moved from other files in julia tests to
663669
# the SparseArrays.jl repo

0 commit comments

Comments
 (0)