numpy / numpy/numpy

BUG/API: np.array([0, max_uint64]) has float64 dtype

Open
#19,146 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
32.8k
Forks
12.8k
Avg merge
1d 7h
Merged PRs (30d)
197

Description

I expected to get uint64

umax = np.iinfo(np.uint64).max

np.array([umax]).dtype   # <-- uint64, as expected

np.array([0, umax]).dtype  # <-- float64, surprising

There seems to be something special going on inference-wise around the int64 bound:

imax = np.iinfo(np.int64).max

np.array([imax, umax]).dtype  # <-- float64

np.array([imax+1, umax]).dtype  # <-- uint64

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the two np.array reproductions in the issue and inspect NumPy's dtype inference entry point for mixed Python integers. Compare the results around the int64 boundary, then add or update regression coverage so [0, np.iinfo(np.uint64).max] and the other shown cases produce the intended dtype.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.