pydata / sparse

Sparse multi-dimensional arrays for the PyData ecosystem

Home Page:https://sparse.pydata.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`einsum` doesn't handle `dtype` and `optimize` kwargs

dcherian opened this issue · comments

Describe the bug
I tried to use np.einsum on a combination of dask and sparse arrays. I get

TypeError: einsum() got an unexpected keyword argument 'dtype'

To Reproduce

import dask
import dask.array as da

data = dask.array.ones((5,5))

wgts = sparse.COO(coords=(0,1,2,3,4), data=[1, 1, 0.5, 1, 1], shape=(5,))
np.einsum('ij,i-> j', data, wgts)

Expected behavior
The output should match the pure numpy version

np.einsum('ij,i-> j', data.compute(), wgts.todense())
array([4.5, 4.5, 4.5, 4.5, 4.5])

System

  • OS and version: macOS 13.3
  • sparse version 0.14.0
  • NumPy version (np.__version__): 1.23.5
  • Numba version (numba.__version__): 0.56.4

Additional context
Add any other context about the problem here.

@mtsokol Again, would this be something you'd be interested in?

Sure! I can take care of it.