scipy.sparse.
isspmatrix#
- scipy.sparse.isspmatrix(x)[source]#
Is x of a sparse matrix type?
Warning
scipy.sparse is switching to the sparse array interface.
The
isspmatrixfunction returnsFalsefor sparse arrays. It will remain after the switch to sparse arrays (sparray). So this is a future proof way to check for sparray vs spmatrix. If you just want to check for sparse, useissparse(A). For more general information about sparrays, see Migration from spmatrix to sparray. The switch to sparse arrays will occur no earlier than v1.21.- Parameters:
- x
object to check for being a sparse matrix
- Returns:
- bool
True if x is a sparse matrix, False otherwise
Examples
>>> import numpy as np >>> from scipy.sparse import csr_array, csr_matrix, isspmatrix >>> isspmatrix(csr_matrix([[5]])) True >>> isspmatrix(csr_array([[5]])) False >>> isspmatrix(np.array([[5]])) False >>> isspmatrix(5) False