Last active
September 25, 2018 20:02
-
-
Save chelseatroy/d1103c4c37643272daf8deb940e2b5b2 to your computer and use it in GitHub Desktop.
toarray implementation in _cs_matrix
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 _cs_matrix(_data_matrix, _minmax_mixin, IndexMixin): | |
... | |
def toarray(self, order=None, out=None): | |
if out is None and order is None: | |
order = self._swap('cf')[0] | |
out = self._process_toarray_args(order, out) | |
if not (out.flags.c_contiguous or out.flags.f_contiguous): | |
raise ValueError('Output array must be C or F contiguous') | |
# align ideal order with output array order | |
if out.flags.c_contiguous: | |
x = self.tocsr() | |
y = out | |
else: | |
x = self.tocsc() | |
y = out.T | |
M, N = x._swap(x.shape) | |
_sparsetools.csr_todense(M, N, x.indptr, x.indices, x.data, y) | |
return out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment