Skip to content

sparse doesn't support shape kwarg in full_like #422

@max-sixty

Description

@max-sixty

Describe the bug
I'm attempting to use NEP18 functionality to include sparse arrays in xarray's unstack refactor: pydata/xarray#4746

I'm not that familiar with the NEP18 interface, but currently I'm getting failures when using np.full_like and including a sparse keyword argument. Even if sparse doesn't require it, could it pass it through to maintain compatibility?

To Reproduce

In [1]: import sparse

In [2]: sparse.ones(5)
Out[2]: <COO: shape=(5,), dtype=float64, nnz=0, fill_value=1.0>

In [3]: x = _

In [4]: import numpy as np

In [12]: np.full_like(x, fill_value=0, shape=(2,2))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-12-cf45b2f0c703> in <module>
----> 1 np.full_like(x, fill_value=0, shape=(2,2))

<__array_function__ internals> in full_like(*args, **kwargs)

/usr/local/lib/python3.8/site-packages/sparse/_sparse_array.py in __array_function__(self, func, types, args, kwargs)
    244             pass
    245         else:
--> 246             return sparse_func(*args, **kwargs)
    247
    248         try:

Expected behavior
A clear and concise description of what you expected to happen.

System

  • OS and version: MacOS
  • sparse version (sparse.__version__) 0.11.2
  • NumPy version (np.__version__) 1.19.2
  • Numba version (numba.__version__) 0.51.2

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions