We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
These work:
sparse.COO @ np.ndarray
sparse.matmul(sparse.COO, np.ndarray)
sparse.matmul(np.ndarray, sparse.COO)
These crash:
np.ndarray @ sparse.COO
np.matmul(sparse.COO, np.ndarray)
np.matmul(np.ndarray, sparse.COO)
Using:
>>> import numpy >>> import sparse >>> a = numpy.zeros((2, 2)) >>> sa = sparse.COO(a) >>> sa @ a array([[0., 0.], [0., 0.]]) >>> a @ sa --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-9-85bcf6384716> in <module> ----> 1 a @ sa /nfs/crusaderky/prg/github/sparse/sparse/coo/core.py in __array_ufunc__(self, ufunc, method, *inputs, **kwargs) 1608 1609 if method == '__call__': -> 1610 result = elemwise(ufunc, *inputs, **kwargs) 1611 elif method == 'reduce': 1612 result = COO._reduce(ufunc, *inputs, **kwargs) /nfs/crusaderky/prg/github/sparse/sparse/coo/umath.py in elemwise(func, *args, **kwargs) 46 """ 47 ---> 48 return _Elemwise(func, *args, **kwargs).get_result() 49 50 /nfs/crusaderky/prg/github/sparse/sparse/coo/umath.py in __init__(self, func, *args, **kwargs) 427 self.cache = {} 428 --> 429 self._get_fill_value() 430 self._check_broadcast() 431 /nfs/crusaderky/prg/github/sparse/sparse/coo/umath.py in _get_fill_value(self) 476 # Some elemwise functions require a dtype argument, some abhorr it. 477 try: --> 478 fill_value_array = self.func(*zero_args, dtype=self.dtype, **self.kwargs) 479 self.dtype = None 480 except TypeError: ValueError: matmul: Input operand 1 does not have enough dimensions (has 0, gufunc core with signature (n?,k),(k,m?)->(n?,m?) requires 1) >>> numpy.matmul(a, sa) (same ValueError as above)
The text was updated successfully, but these errors were encountered:
For matmul, we'd need to special-case anything that's a gufunc but not a regular ufunc in __array_ufunc__. Are you willing to submit a patch for this?
matmul
__array_ufunc__
Sorry, something went wrong.
(We'd need to route it through __array_function__).
__array_function__
Successfully merging a pull request may close this issue.
Uh oh!
There was an error while loading. Please reload this page.
These work:
sparse.COO @ np.ndarray
sparse.matmul(sparse.COO, np.ndarray)
sparse.matmul(np.ndarray, sparse.COO)
These crash:
np.ndarray @ sparse.COO
np.matmul(sparse.COO, np.ndarray)
np.matmul(np.ndarray, sparse.COO)
Using:
The text was updated successfully, but these errors were encountered: