scipy.sparse.
issparse#
- scipy.sparse.issparse(x)[Quelle]#
Ist x vom Typ Sparse-Array oder Sparse-Matrix?
- Parameter:
- x
Objekt, das auf Sparse-Array oder Sparse-Matrix geprüft werden soll
- Rückgabe:
- bool
True, wenn x ein Sparse-Array oder eine Sparse-Matrix ist, sonst False
Hinweise
Verwenden Sie isinstance(x, sp.sparse.sparray), um zwischen einem Array und einer Matrix zu unterscheiden. Verwenden Sie a.format, um das Sparse-Format zu überprüfen, z. B. a.format == ‘csr’.
Beispiele
>>> import numpy as np >>> from scipy.sparse import csr_array, csr_matrix, issparse >>> issparse(csr_matrix([[5]])) True >>> issparse(csr_array([[5]])) True >>> issparse(np.array([[5]])) False >>> issparse(5) False