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

Comments

Projects
None yet
2 participants
@ahwillia
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

This comment has been minimized.

Collaborator

hameerabbasi commented May 3, 2018

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

@hameerabbasi

This comment has been minimized.

Collaborator

hameerabbasi commented May 3, 2018

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.

@mrocklin mrocklin closed this in #148 May 3, 2018

@ahwillia

This comment has been minimized.

Contributor

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