Skip to content
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

math.isfinite fails with Decimal sNAN #63041

Closed
stevendaprano opened this issue Aug 26, 2013 · 4 comments
Closed

math.isfinite fails with Decimal sNAN #63041

stevendaprano opened this issue Aug 26, 2013 · 4 comments
Labels
docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@stevendaprano
Copy link
Member

BPO 18841
Nosy @rhettinger, @facundobatista, @mdickinson, @stevendaprano, @skrah

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2016-05-06.12:35:27.081>
created_at = <Date 2013-08-26.15:38:40.605>
labels = ['type-bug', 'library', 'docs']
title = 'math.isfinite fails with Decimal sNAN'
updated_at = <Date 2016-05-06.12:35:27.080>
user = 'https://github.com/stevendaprano'

bugs.python.org fields:

activity = <Date 2016-05-06.12:35:27.080>
actor = 'berker.peksag'
assignee = 'docs@python'
closed = True
closed_date = <Date 2016-05-06.12:35:27.081>
closer = 'berker.peksag'
components = ['Documentation', 'Library (Lib)']
creation = <Date 2013-08-26.15:38:40.605>
creator = 'steven.daprano'
dependencies = []
files = []
hgrepos = []
issue_num = 18841
keywords = []
message_count = 4.0
messages = ['196213', '224662', '224928', '229309']
nosy_count = 7.0
nosy_names = ['rhettinger', 'facundobatista', 'mark.dickinson', 'steven.daprano', 'skrah', 'docs@python', 'BreamoreBoy']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue18841'
versions = ['Python 3.4']

@stevendaprano
Copy link
Member Author

math.isfinite currently raises ValueError when given a Decimal sNAN (signalling NAN).

I've run into a situation where I'm calling isfinite() on a numeric value which may be a Decimal sNAN, and it would be nice if it returned False.

On the other hand, see the discussion on bpo-15544, which possibly leads to the conclusion that raising ValueError is the right thing to do.

http://bugs.python.org/issue15544

Either way, behaviour should be documented.

@stevendaprano stevendaprano added docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Aug 26, 2013
@BreamoreBoy
Copy link
Mannequin

BreamoreBoy mannequin commented Aug 3, 2014

Steven, can you propose a patch for this?

@mdickinson
Copy link
Member

Mark: it's not really ready for a patch, since there's no agreement yet on how best to solve this. In fact, I'm tempted to close as "wont fix": the argument is that the math module consists for the most part only of thin wrappers around the platform math library.

The underlying need (as far as I understand it) is to be able to tell whether a given number is a nan or not without having to know in advance whether it's a float, int or Decimal instance. There may be other ways of achieving this goal (like adding an is_nan method to float and int, for example.)

@skrah
Copy link
Mannequin

skrah mannequin commented Oct 14, 2014

"Wont fix" sounds good to me.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants