Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zeros_like return COO format even if DOK is asked #380

Closed
jodemaey opened this issue Jul 9, 2020 · 2 comments · Fixed by #381
Closed

zeros_like return COO format even if DOK is asked #380

jodemaey opened this issue Jul 9, 2020 · 2 comments · Fixed by #381
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@jodemaey
Copy link

jodemaey commented Jul 9, 2020

Bug description

Maybe it is normal behavior but imho it shoud not be. zeros_like function return COO format even if DOK is asked.

Example

In[1]: import numpy as np
In[2]: import sparse as sp
In[3]: a = np.random.random((10,10,10))
In[4]: s = sp.zeros_like(a, format='dok')
In[5]: s
Out[5]: <COO: shape=(10, 10, 10), dtype=float64, nnz=0, fill_value=0.0>

Note that even starting from a COO and asking for a DOK doesn't work:

In[6]: d = sp.zeros_like(s, format='dok')
In[7]: d
Out[7]: <COO: shape=(10, 10, 10), dtype=float64, nnz=0, fill_value=0.0>

Expected behavior

zeros_like should return DOK format if DOK format is asked.

System

  • OS and version: Ubuntu 18.04.4 LTS (kernel 5.3.0-62-generic)
  • Python 3.8.3
  • sparse version: 0.10.0 (from conda-forge)
  • NumPy version: 1.18.5
  • Numba version: 0.50.1

Additional comment

I looked for a previous notice of this bug but found none. Sorry if it was already reported.
For the moment, I bypass this by using zeros (which works) instead.

@jodemaey jodemaey added the bug Indicates an unexpected problem or unintended behavior label Jul 9, 2020
@hameerabbasi
Copy link
Collaborator

Thanks for reporting this issue. I can reproduce and have a tentative fix in #381.

@hameerabbasi
Copy link
Collaborator

This should now be fixed in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants