Skip to content

Commit b3872c8

Browse files
authored
added warning for iterating while mutating a sparse matrix (#415)
1 parent f8f0f40 commit b3872c8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/sparsematrix.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,9 @@ column. In conjunction with [`nonzeros`](@ref) and
294294
# perform sparse wizardry...
295295
end
296296
end
297+
298+
!!! warning
299+
Adding or removing nonzero elements to the matrix may invalidate the `nzrange`, one should not mutate the matrix while iterating.
297300
"""
298301
nzrange(S::AbstractSparseMatrixCSC, col::Integer) = getcolptr(S)[col]:(getcolptr(S)[col+1]-1)
299302
nzrange(S::SparseMatrixCSCView, col::Integer) = nzrange(S.parent, S.indices[2][col])

0 commit comments

Comments
 (0)