def tocoo(self):
from .coo import coo_matrix<EOL>if self.nnz == <NUM_LIT:0>:<EOL><INDENT>return coo_matrix(self.shape, dtype=self.dtype)<EOL><DEDENT>else:<EOL><INDENT>idx_dtype = get_index_dtype(maxval=max(self.shape[<NUM_LIT:0>], self.shape[<NUM_LIT:1>]))<EOL>data = np.asarray(_list(self.values()), dtype=self.dtype)<EOL>indices = np.asarray(_list(self.keys()), dtype=idx_dtype).T<EOL>return coo_matrix((data,indices), shape=self.shape, dtype=self.dtype)<EOL><DEDENT>
Return a copy of this matrix in COOrdinate format