-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Open
Labels
defectA clear bug or issue that prevents SciPy from being installed or used as expectedA clear bug or issue that prevents SciPy from being installed or used as expectedneeds-decisionItems that need further discussion before they are merged or closedItems that need further discussion before they are merged or closedscipy.sparse
Description
Some sparse matrix formats store explicit zero-valued elements (see e.g.
Line 157 in eef58eb
explicit zero values are included in this number |
* explicit zeros are treated as nonzero. |
scipy/scipy/sparse/sparsetools/csr.h
Line 445 in 84bc568
* Explicit zeros in A are carried over to B. |
I know that in some applications of sparse matrices in which implicit zeros have different semantics (e.g. unknown value), explicit zeros are exploited, such as for data imputation.
It seems explicit zeros are maintained in matrix conversion to CSR, CSC, BSR, COO and DOK, but not to LIL.
To my knowledge the properties of the sparse matrix implementations with respect to explicit zeros are undocumented and untested. I presume they should be.
For an example of inconsistency:
>>> A = sp.coo_matrix([[0]])
>>> A.nnz
0
>>> B = A.tocsr()
>>> B[0, 0] = 0
>>> B.nnz
1
>>> B = A.todok()
>>> B[0, 0] = 0
>>> B.nnz
0
>>> B = A.tolil()
>>> B[0, 0] = 0
>>> B.nnz
0
What is correct behaviour?
arashgmn
Metadata
Metadata
Assignees
Labels
defectA clear bug or issue that prevents SciPy from being installed or used as expectedA clear bug or issue that prevents SciPy from being installed or used as expectedneeds-decisionItems that need further discussion before they are merged or closedItems that need further discussion before they are merged or closedscipy.sparse