DOC: explicitly state that `count_nonzero` with `axis=()` is unspecified.
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- numpy, pytorch
- Domain
- documentation
Research direction
Start with the count_nonzero specification at the linked API page, then identify the other reduction-like functions that accept tuple values for axis. Update the relevant documentation to state that axis=() behavior is unspecified and implementation-defined, and verify that the wording covers the intended functions.
Written by the indexing model from the issue text.
Description
The current docs [1] only state that If a tuple of integers, the number of non-zero values must be computed over multiple axes.
[1] https://data-apis.org/array-api/draft/API_specification/generated/array_api.count_nonzero.html
While one could argue that an empty tuple is not a tuple of integers, it could still be worth it to explicitly state that the behavior with axis=() is unspecificed and thus implementation-defined.
IRL, it is implementation-defined:
In [5]: a = np.arange(3*4*5).reshape(3, 4, 5)
In [6]: np.count_nonzero(a, axis=()).shape
Out[6]: (3, 4, 5)
In [7]: torch.count_nonzero(torch.as_tensor(a), dim=())
Out[7]: tensor(59)
In fact, it'd be best to add the same phrasing to all reduction-like functions which accept tuples for axis.
- Dominant language
- Python
- Stars
- 281
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from data-apis/array-api
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Maintenance
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
All issues in data-apis/array-api
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100