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

COO.__matmul__ returns a np.ndarray instead of a COO #201

Closed
gongliyu opened this Issue Oct 22, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@gongliyu
Copy link
Contributor

gongliyu commented Oct 22, 2018

COO.matmul should return a sparse.COO, but returns a np.ndarray instead

In [1]: import numpy as np

In [2]: import sparse

In [3]: npx = np.random.random((1,2,3,4))

In [4]: npy = np.random.random((1,2,4,3))

In [5]: npz = npx @ npy

In [6]: npz.shape
Out[6]: (1, 2, 3, 3)

In [7]: spx = sparse.random((1,2,3,4), 0.8)

In [8]: spy = sparse.random((1,2,4,3), 0.8)

In [9]: spz = spx @ spy

In [10]: type(spz)
Out[10]: numpy.ndarray

In [11]: spz.shape
Out[11]: (1, 2, 3, 1, 2, 3)
@hameerabbasi

This comment has been minimized.

Copy link
Collaborator

hameerabbasi commented Oct 22, 2018

Hi! Could you report both these issues as separate for better tracking?

@gongliyu gongliyu changed the title COO.__matmul__ behaves unreasonably COO.__matmul__ returns a np.ndarray (supposed to be a sparse.COO) Oct 22, 2018

@gongliyu gongliyu changed the title COO.__matmul__ returns a np.ndarray (supposed to be a sparse.COO) COO.__matmul__ returns a np.ndarray instead of a COO Oct 22, 2018

@hameerabbasi

This comment has been minimized.

Copy link
Collaborator

hameerabbasi commented Oct 22, 2018

There was some legacy behaviour left behind where we would auto-densify for performance reasons. Now, sparse @ sparse is sparse and sparse @ dense and dense @ sparse are both dense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment