Skip to content

ENH: float.from_number implementation #29077

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ganesh-k13
Copy link
Member

@ganesh-k13 ganesh-k13 commented May 28, 2025

Changes

Add float.from_number for floating types

Testing

In [3]: np.float16.from_number(7), type(np.float16.from_number(7))
Out[3]: (np.float16(7.0), numpy.float16)

In [4]: np.float16.from_number(100000000000000000)
Out[4]: np.float16(inf)

In [5]: np.float16.from_number('a')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: must be real number, not str

Related

part of #13375

Todo

  • release notes
  • UT
  • typing
  • docs

@ganesh-k13 ganesh-k13 self-assigned this May 28, 2025
@ganesh-k13 ganesh-k13 added 56 - Needs Release Note. Needs an entry in doc/release/upcoming_changes 62 - Python API Changes or additions to the Python API. Mailing list should usually be notified. labels May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
01 - Enhancement 56 - Needs Release Note. Needs an entry in doc/release/upcoming_changes 62 - Python API Changes or additions to the Python API. Mailing list should usually be notified.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy