sparse: SystemError for COO.dot with NumPy 1.20
Describe the bug
a.dot(a) raises a SystemError (and TypeError) with the latest version of sparse and NumPy 1.20.
To Reproduce
In [1]: import sparse
In [2]: a = sparse.zeros((4, 4))
In [4]: a.dot(a)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: expected dtype object, got 'numpy.dtype[float64]'
The above exception was the direct cause of the following exception:
SystemError                               Traceback (most recent call last)
<ipython-input-4-569a015a6581> in <module>
----> 1 a.dot(a)
~/Envs/dask-dev/lib/python3.7/site-packages/sparse/_coo/core.py in dot(self, other)
   1675                [ 6, 11]], dtype=int64)
   1676         """
-> 1677         return dot(self, other)
   1678
   1679     def __matmul__(self, other):
~/Envs/dask-dev/lib/python3.7/site-packages/sparse/_coo/common.py in dot(a, b)
    291     if b.ndim == 1:
    292         b_axis = -1
--> 293     return tensordot(a, b, axes=(a_axis, b_axis))
    294
    295
~/Envs/dask-dev/lib/python3.7/site-packages/sparse/_coo/common.py in tensordot(a, b, axes, return_type)
    172     at = a.transpose(newaxes_a).reshape(newshape_a)
    173     bt = b.transpose(newaxes_b).reshape(newshape_b)
--> 174     res = _dot(at, bt, return_type)
    175     return res.reshape(olda + oldb)
    176
~/Envs/dask-dev/lib/python3.7/site-packages/sparse/_coo/common.py in _dot(a, b, return_type)
    301         b = b.T
    302         coords, data = _dot_coo_coo_type(a.dtype, b.dtype)(
--> 303             a.coords, a.data, b.coords, b.data
    304         )
    305
SystemError: CPUDispatcher(<function _dot_coo_coo_type.<locals>._dot_coo_coo at 0x11a0ec8c0>) returned a result with an error set
In [6]: np.__version__
Out[6]: '1.20.0.dev0+4771e3f'
Expected behavior
With NumPy<= 1.19
In [4]: a.dot(a)
Out[4]: <COO: shape=(4, 4), dtype=float64, nnz=0, fill_value=0.0>
System
- OS and version: [MacOS 10.14.5]
 sparseversion (0.10.0+13.g2243192)- NumPy version (
'1.20.0.dev0+4771e3f) - Numba version (
'0.50.1') 
Additional context Add any other context about the problem here.
It’s not clear to me yet if the issue is in sparse or numba. Do you have any tips for differentiating that?
About this issue
- Original URL
 - State: closed
 - Created 4 years ago
 - Comments: 15 (6 by maintainers)
 
I think the systemerror is caused by the numba tuple boxer being broken.
The SystemError was raised due to that exception, which was the root cause.
Just replace the
returnline withThe fact that this gives SystemError is a pretty strong indication that this is a numba bug.