Last active
September 26, 2018 04:08
-
-
Save chelseatroy/105adcca9ef82d18c52de043bfe528fb to your computer and use it in GitHub Desktop.
nonzero alternative implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class coo_1d(_data_matrix, ...): | |
... | |
def row(self): | |
return np.zeros(self.col.shape[0]) | |
def nonzero(self): | |
... | |
nz_mask = A.data != 0 | |
return (None, A.col[nz_mask]) | |
class coo_2d(_data_matrix, ...): | |
... | |
def nonzero(self): | |
... | |
A = self.tocoo() | |
nz_mask = A.data != 0 | |
return (A.row[nz_mask], A.col[nz_mask]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment