Skip to content

BUG: Printing float16 with NumPy>=2.0 gives overflow warning #61029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rhshadrach opened this issue Mar 1, 2025 · 3 comments
Closed

BUG: Printing float16 with NumPy>=2.0 gives overflow warning #61029

rhshadrach opened this issue Mar 1, 2025 · 3 comments
Assignees
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string Warnings Warnings that appear or should be added to pandas

Comments

@rhshadrach
Copy link
Member

print(pd.Series([1.0], dtype="float16"))
# RuntimeWarning: overflow encountered in cast np.array([1.0], dtype="float16") > 1e6
# 0    1.0
# dtype: float16

This occurs here:

has_large_values = (abs_vals > 1e6).any()

Perhaps we just set has_large_values to be false for float16?

@rhshadrach rhshadrach added Bug Output-Formatting __repr__ of pandas objects, to_string Warnings Warnings that appear or should be added to pandas labels Mar 1, 2025
@Pedro-Santos04
Copy link

take

@mroeschke
Copy link
Member

I know we disallow float16 in Index and in many places upcast float16 inputs to float32/float64. I think eventually we should deprecate float16 supports everywhere

@rhshadrach
Copy link
Member Author

Thanks @mroeschke - searching through the issues I see now that it was never really supported in pandas. I'll remove it from the docs in #60987.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string Warnings Warnings that appear or should be added to pandas
Projects
None yet
Development

No branches or pull requests

3 participants