array-api
array-api copied to clipboard
feat: add `count_nonzero` to specification
This PR
- resolves https://github.com/data-apis/array-api/issues/794 by adding support for counting the number of non-zero values to the specification.
- is consistent with statistical functions (such as
max,mean,sum, etc) in supporting one or more axes over which to perform the reduction and in supportingkeepdimsto ensure the returned result is broadcast compatible. - follows
nonzeros(ref: https://github.com/data-apis/array-api/pull/23#issuecomment-680784657) in disallowing zero-dimensional input arrays. Note, however, that the statistical function APIs do not contain any explicit guidance regarding minimum rank. - updates
nonzerosby moving the notes to a dedicated notes section (i.e., below the "fold").