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

Grabbing nonzero indices #145

Closed
ahwillia opened this issue May 2, 2018 · 3 comments
Closed

Grabbing nonzero indices #145

ahwillia opened this issue May 2, 2018 · 3 comments

Comments

@ahwillia
Copy link
Contributor

ahwillia commented May 2, 2018

Is the preferred way to access the coordinates/indices to use something like

i, j, k = arr.coords  # for a 3d array

Is there a reason why coo arrays don't implement nonzero as a method? I think this would make np.argwhere(arr) work as well without converting to a dense array.

Huge thanks for developing this package -- it will be very useful to me.

@hameerabbasi
Copy link
Collaborator

Thanks for the tip! There is a sparse.where method equivalent to np.where that you can use.

@hameerabbasi
Copy link
Collaborator

As you know, the ndarray API is relatively large, and it's hard for a project with not many developers to implement it all. In any case, I've implemented your suggestion in #148 (it was relatively simple), and added a test both for the nonzero method and for np.argwhere. I encourage you to take a look if you find the time.

@ahwillia
Copy link
Contributor Author

ahwillia commented May 3, 2018

Awesome, thanks so much for implementing this so quickly! I'd be happy to help in the future if there are more improvements along these lines.

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

No branches or pull requests

2 participants