pydata / sparse

Sparse multi-dimensional arrays for the PyData ecosystem
https://sparse.pydata.org
BSD 3-Clause "New" or "Revised" License
581 stars 123 forks source link

`to_coo` raises DeprecationWarning #679

Closed aeisenbarth closed 2 months ago

aeisenbarth commented 2 months ago

Describe the bug When constructing a matrix with sparse.DOK and converting it to COO, it always raises "DeprecationWarning: coords should be an ndarray", although I do not provide coords at all. Internally, sparse passes the DOK instance instead of a Numpy array.

To Reproduce

python -Werror -c "import sparse; sparse.DOK(shape=(1, 1)).to_coo()"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "…/lib/python3.9/site-packages/sparse/_dok.py", line 210, in to_coo
    return COO(self)
  File "…/lib/python3.9/site-packages/sparse/_coo/core.py", line 215, in __init__
    warnings.warn(
DeprecationWarning: coords should be an ndarray. This will raise a ValueError in the future.

Expected behavior No warning is raised.

System

hameerabbasi commented 2 months ago

We're considering deprecating to_coo/tocoo methods completely, please use .asformat("coo") or .asformat(sparse.COO) instead.