linspace with int dtype sometimes doesn't include endpoints
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 32.8k
- Forks
- 12.8k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 197
Description
>>> np.linspace(-9007199254740993, 0, 1, dtype=np.int64)
array([-9007199254740992])
>>> np.linspace(0, 9007199254740993, 2, dtype=np.uint64, endpoint=True)
array([ 0, 9007199254740992], dtype=uint64)
>>> np.__version__
'1.21.0.dev0+1420.gc2dd42fda'
(notice that the last digit has been changed from a 3 to a 2)
It's not clear to me if this should be considered a bug, or if this is expected from the way linspace inherently has to do rounding.
I found https://github.com/numpy/numpy/issues/16813 which seems related.
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 reported np.linspace examples with the shown integer dtypes and compare the behavior discussed in NumPy issue #16813. Determine the expected endpoint and rounding semantics for these cases, then verify the behavior with focused regression coverage; done means the endpoint behavior is defined and the reported examples are handled consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100