np.choose does not work for a zero-length sequence
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 32.8k
- Forks
- 12.8k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 197
Description
These all work:
>>> np.choose(np.ones(2, dtype=np.intp), np.zeros((5, 2)))
array([ 0., 0.])
>>> np.choose(np.ones(1, dtype=np.intp), np.zeros((5, 1)))
array([ 0.])
>>> np.choose(np.ones(0, dtype=np.intp), np.zeros((5, 0)))
array([])
So why does this not? (I would expect the output in both cases to be array([]))
>>> np.choose(np.ones(0, dtype=np.intp), np.zeros((0, 5)))
ValueError: 0-length sequence.
>>> np.choose(np.ones(0, dtype=np.intp), np.zeros((0, 0)))
ValueError: 0-length sequence.
Is there anything semantically wrong in saying "from a set of no sequences, each containing 5 elements, pick the corresponding item from this set of no indices"?
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.
Research direction
Start by reproducing the two failing np.choose examples and locating the np.choose implementation and its existing tests. The work is done when both zero-length cases return array([]) consistently with the working examples, with regression coverage for the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 57/100