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

Add sum to _sparse_py_operators #522

Closed
aerubanov opened this issue Jul 12, 2021 · 5 comments · Fixed by #745
Closed

Add sum to _sparse_py_operators #522

aerubanov opened this issue Jul 12, 2021 · 5 comments · Fixed by #745
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed SciPy compatibility sparse tensors

Comments

@aerubanov
Copy link
Contributor

aerubanov commented Jul 12, 2021

When working on pymc-devs/pymc#4596, I needed the sum() method for sparse matrices for doing things like these:

import numpy as np, aesara as as

 W = np.array(
            [[0.0, 1.0, 1.0, 0.0], [1.0, 0.0, 0.0, 1.0], [1.0, 0.0, 0.0, 1.0], [0.0, 1.0, 1.0, 0.0]]
        )
W = as.tensor.as_tensor_variable(W)
W = as.sparse.csr_from_dense(W)
D = W.sum(axis=0)

and as a result, D should be dense vector [2.0, 2.0, 2.0, 2.0].

@twiecki twiecki added good first issue Good for newcomers help wanted Extra attention is needed labels Jul 12, 2021
@twiecki
Copy link
Contributor

twiecki commented Jul 12, 2021

@aerubanov Can you add more complete example code that imports modules and creates a sparse matrix?

@brandonwillard
Copy link
Member

There is already support for sums on sparse matrices; see here. If you're having specific issues with this functionality, you can open another issue or update this one with a minimum working example; otherwise, I'll assume this particular issue is only about adding a sum method.

@aerubanov
Copy link
Contributor Author

@brandonwillard Thank you, looks like it is exactly what I need! I just couldn't find it in the documentation. So I close the issue.

@brandonwillard
Copy link
Member

We should still have a sum method, so I'm reopening it for that.

@brandonwillard brandonwillard changed the title Add sum() operation for sparse matrices Add sum to _sparse_py_operators Jul 12, 2021
@aerubanov
Copy link
Contributor Author

This feature was implemented in #745, so I close issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed SciPy compatibility sparse tensors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants