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

asformat('{csr,csc}') doesn't work on DOK and COO #503

Closed
sayandip18 opened this issue Jul 8, 2021 · 2 comments · Fixed by #504
Closed

asformat('{csr,csc}') doesn't work on DOK and COO #503

sayandip18 opened this issue Jul 8, 2021 · 2 comments · Fixed by #504
Labels

Comments

@sayandip18
Copy link
Contributor

Describe the bug
asformat() does not support conversion of COO and DOK to csr or csc although the same is supported for GCXS.

To Reproduce

>>> import sparse; s=sparse.random((5,5))
>>> s
<COO: shape=(5, 5), dtype=float64, nnz=0, fill_value=0.0>
>>> s.asformat('csc')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sayandip/sparse/sparse/_coo/core.py", line 1452, in asformat
    raise NotImplementedError("The given format is not supported.")
NotImplementedError: The given format is not supported.
>>> 
>>> s=sparse.random((5,5), format='dok')
>>> s.asformat('csc')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sayandip/sparse/sparse/_dok.py", line 524, in asformat
    raise NotImplementedError("The given format is not supported.")
NotImplementedError: The given format is not supported.
>>> 
>>> s=sparse.random((5,5), format='gcxs')
>>> s
<GCXS: shape=(5, 5), dtype=float64, nnz=0, fill_value=0.0, compressed_axes=(0,)>
>>> s.asformat('csc')
<CSC: shape=(5, 5), dtype=float64, nnz=0, fill_value=0.0>

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

System

  • OS: Ubuntu 20.04.1
  • sparse version: master

Additional context
tocsr and tocsc work as expected for COO object.

@hameerabbasi hameerabbasi changed the title asformat() bug asformat('{csr,csc}') doesn't work on DOK and COO Jul 8, 2021
@hameerabbasi
Copy link
Collaborator

Beware that in fixing this I took away the ability to add compressed_axis=something everywhere, just passing through the kwargs. This usually means compressed_axes can only be supplied if format was GCXS.

@hameerabbasi
Copy link
Collaborator

This might conflict a bit with your Hypothesis PR, @sayandip18 but if you follow the small test changes I made, it should be okay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants