-
Notifications
You must be signed in to change notification settings - Fork 48
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
RFC: add count_nonzero
for counting the number of "non-zero" values
#794
Comments
@asmeurer can you tell us if it's easy to work around a missing |
One other nice thing is that unlike nonzero, this function does not have a data-dependent output shape. So aside from performance, it can be supported by implementations that may not support |
The |
I think so. Isn't it just a matter of calling expand_dims? Maybe #760 would help. |
To reiterate what I said at the meeting today, |
Thanks! SGTM then to add |
PR is up: #803 |
This RFC proposes a new addition to the array API specification for counting the number of "non-zero" (i.e., truthy) values in an array.
Overview
Based on array comparison data, the API is available across all major array libraries in the PyData ecosystem.
count_nonzero
was originally identified in #187 as a potential standardization candidate and has usage within downstream libraries (e.g., sklearn, SciPy).Prior art
keepdims
.keepdims
.keepdims
and was not discussed upon initial addition (ref).Proposal
axis
isNone
, the function should count the number of non-zero elements along a flattened array.Questions
sum
and other reductions, support forkeepdims
is less common among array libraries. Why this is the case is not clear. Are there any reasons whykeepdims
should not be standardized?The text was updated successfully, but these errors were encountered: