Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support creating lazy arrays from SciPy sparse matrices #1

Open
apdavison opened this issue Jul 19, 2017 · 0 comments
Open

Support creating lazy arrays from SciPy sparse matrices #1

apdavison opened this issue Jul 19, 2017 · 0 comments

Comments

@apdavison
Copy link
Member

apdavison commented Jul 19, 2017

from https://bitbucket.org/apdavison/lazyarray/issues/1/support-creating-lazy-arrays-from-scipy

Examples:

>>> row = np.array([0, 2, 2, 0, 1, 2])
>>> col = np.array([0, 0, 1, 2, 2, 2])
>>> data = np.array([1, 2, 3, 4, 5, 6])
>>> sparr = csc_matrix((data, (row, col)), shape=(3, 3))
>>> sparr.toarray()
array([[1, 0, 4],
       [0, 0, 5],
       [2, 3, 6]])
>>> larr = larray(sparr)
>>> larr.shape
(3, 3)
>>> larr.dtype
dtype('int64')
>>> larr.evaluate()
array([[1, 0, 4],
       [0, 0, 5],
       [2, 3, 6]])
>>> larr.evaluate(empty_val=np.nan)
array([[1, nan, 4],
       [nan, nan, 5],
       [2, 3, 6]])
>>> larr[2, :]
array([2, 3, 6])
>>> larr.base_value
<3x3 sparse matrix of type '<class 'numpy.int64'>'
	with 6 stored elements in Compressed Sparse Column format>
apdavison added a commit that referenced this issue Sep 12, 2017
Support creating lazy arrays from SciPy sparse matrices (see #1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant