Skip to content

sparse + dask array not supported #5259

@shoyer

Description

@shoyer

cc @hameerabbasi

dask+sparse works, but not sparse+dask.

I think dask should probably implement this case, via it's __array_ufunc__ method. Here's the traceback:

In [1]: import sparse

In [2]: import dask.array as da

In [3]: import numpy as np

In [4]: x = np.arange(3)

In [5]: y = sparse.COO(x)

In [6]: z = da.from_array(y, chunks=3)

In [7]: z + y
Out[7]: dask.array<add, shape=(3,), dtype=int64, chunksize=(3,)>

In [8]: y + z
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-8-ff96b8185f8d> in <module>
----> 1 y + z

~/miniconda3/envs/xarray-py37-dev/lib/python3.7/site-packages/numpy/lib/mixins.py in func(self, other)
     23         if _disables_array_ufunc(other):
     24             return NotImplemented
---> 25         return ufunc(self, other)
     26     func.__name__ = '__{}__'.format(name)
     27     return func

TypeError: operand type(s) all returned NotImplemented from __array_ufunc__(<ufunc 'add'>, '__call__', <COO: shape=(3,), dtype=int64, nnz=2, fill_value=0>, dask.array<array, shape=(3,), dtype=int64, chunksize=(3,)>): 'COO', 'Array'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions