Skip to content

Preserve formatting and precision of NumPy unsigned integers - #493

Open
Sskift wants to merge 2 commits into
astanin:masterfrom
Sskift:fix/numpy-unsigned-integers
Open

Sskift wants to merge 2 commits into
astanin:masterfrom
Sskift:fix/numpy-unsigned-integers

Conversation

@Sskift

@Sskift Sskift commented Nov 2, 2026

Copy link
Copy Markdown

Summary

Unsigned NumPy integers are currently classified as floats. This bypasses intfmt and can lose precision: formatting numpy.uint64(2**64 - 1) with floatfmt=".0f" produces 18446744073709551616 instead of 18446744073709551615.

Recognize NumPy integer scalars by their integral type and integer dtype. The dtype check keeps NumPy durations out of the integer path, while the NumPy type restriction preserves the behavior of Python booleans, enums, and other values.

Regression tests cover signed and unsigned integer types and the longlong aliases, comma and hexadecimal integer formats, and list, NumPy-array, and DataFrame inputs.

Validation

  • Before the fix: 27 failing regressions and 34 passing controls. After the fix: all 61 pass.
  • Full suite including doctests: 443 passed, 1 skipped on CPython 3.12 / Windows, NumPy 2.5.4 and pandas 3.1.0.
  • Entire-repository Ruff checks, formatting checks, and git diff --check pass.

AI-assisted implementation and testing, with independent review by a separate AI agent. No human review is claimed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant