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

Reduce operations raise error for negative axis values #117

Closed
nils-werner opened this issue Mar 2, 2018 · 2 comments
Closed

Reduce operations raise error for negative axis values #117

nils-werner opened this issue Mar 2, 2018 · 2 comments
Labels

Comments

@nils-werner
Copy link
Contributor

@nils-werner nils-werner commented Mar 2, 2018

Reduce operations like .sum(), .prod() etc. raise exceptions when you pass a negative axis value:

import sparse
sparse.random((40, 50)).sum(0)  # works
sparse.random((40, 50)).sum(1)  # works
sparse.random((40, 50)).sum(-1)  # fails, should be equivalent to .sum(1)

The traceback I get:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "proj_dir/sparse/sparse/coo.py", line 1038, in prod
    return self.reduce(np.multiply, axis=axis, keepdims=keepdims, dtype=dtype)
  File "proj_dir/sparse/sparse/coo.py", line 771, in reduce
    a = self.transpose(neg_axis + axis)
  File "proj_dir/sparse/sparse/coo.py", line 1099, in transpose
    raise ValueError("repeated axis in transpose")
ValueError: repeated axis in transpose
@nils-werner nils-werner changed the title Reduce operations raise error on negative axes Reduce operations raise error for negative axis values Mar 2, 2018
@hameerabbasi
Copy link
Collaborator

@hameerabbasi hameerabbasi commented Mar 2, 2018

@nils-werner Are you interested in fixing this? It's trivial. You just need to flip the axes to be positive near the top of COO.reduce.

@nils-werner
Copy link
Contributor Author

@nils-werner nils-werner commented Mar 2, 2018

Yeah, I can do that.

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

Successfully merging a pull request may close this issue.

2 participants