Skip to content

intN: name the actual type in the out-of-range OverflowError - #403

Open
EylonKrause wants to merge 1 commit into
jax-ml:mainfrom
EylonKrause:fix/intn-out-of-range-message
Open

EylonKrause wants to merge 1 commit into
jax-ml:mainfrom
EylonKrause:fix/intn-out-of-range-message

Conversation

@EylonKrause

Copy link
Copy Markdown

The out-of-range message in the intN scalar/setitem conversion is a constant that always says int4:

>>> ml_dtypes.uint4(16.0)
OverflowError: out of range value cannot be converted to int4
>>> ml_dtypes.int2(np.int64(2))
OverflowError: out of range value cannot be converted to int4

Format it with the type's kTypeName instead (... cannot be converted to uint4), and have testCastFailure check the name for the Python float, NumPy float and NumPy integer paths. No behaviour change otherwise; intn_test.py and the rest of the suite pass.

Disclosure: this contribution was authored with an AI coding assistant (Claude) and reviewed before submission.

🤖 Generated with Claude Code

The message was a constant that always said "int4", so an out-of-range
uint4/int2/uint2/int1/uint1 value reported the wrong type. Format it with
the type's name instead, and check the name in testCastFailure.
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