Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Should nan == nan be False?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Aaron Meurer  
View profile  
 More options Dec 6 2011, 7:45 pm
From: Aaron Meurer <asmeu...@gmail.com>
Date: Tue, 6 Dec 2011 17:45:10 -0700
Local: Tues, Dec 6 2011 7:45 pm
Subject: Should nan == nan be False?
Hi.

I just noticed that in mpmath, we have

In [260]: mpf('nan') == mpf('nan')
Out[260]: False

This is because of the code (in libmpf.py):

def mpf_eq(s, t):
    """Test equality of two raw mpfs. This is simply tuple comparion
    unless either number is nan, in which case the result is False."""
    if not s[1] or not t[1]:
        if s == fnan or t == fnan:
            return False
    return s == t

Is this intentional, or just an overlooked side effect of making
nothing compare equal to nan?

This is causing problems in SymPy, where we are having to use a
workaround (testing Float._mpf_ == fnan) to make our infinities play
nicely with the Float wrappers of mpmath infinites.  See
https://github.com/sympy/sympy/pull/789.

P.S. there is apparently a typo in the docstring of mpf_eq.
"comparion" should be "comparison".

Aaron Meurer


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fredrik Johansson  
View profile  
 More options Dec 7 2011, 2:11 pm
From: Fredrik Johansson <fredrik.johans...@gmail.com>
Date: Wed, 7 Dec 2011 20:11:35 +0100
Local: Wed, Dec 7 2011 2:11 pm
Subject: Re: Should nan == nan be False?

It's intended for compatibility with floats. I was never a fan of this
convention, but I would rather not change it at this point.

> P.S. there is apparently a typo in the docstring of mpf_eq.
> "comparion" should be "comparison".

Thanks, fixed!

Fredrik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron Meurer  
View profile  
 More options Dec 7 2011, 3:35 pm
From: Aaron Meurer <asmeu...@gmail.com>
Date: Wed, 7 Dec 2011 13:35:15 -0700
Local: Wed, Dec 7 2011 3:35 pm
Subject: Re: Should nan == nan be False?
On Wed, Dec 7, 2011 at 12:11 PM, Fredrik Johansson

I see.  This was actually pointed out to me after I wrote this email.
Any idea why they did that?

So how would you recommend that we do things with Float in SymPy.  We
can either keep it like it is, but add some kind of way to tell if
it's nan.  Right now, we are testing Float._mpf_ against fnan from
mpmath.libmp.libmpf which is not very stable, and also not very
user-friendly.  So we would add some kind of .is_nan property.  Or, we
can break this convention, and have Float('nan') == Float('nan') be
True.

There's also the question of how this should behave with SymPy's S.NaN
if we choose the first option.  Right now, we have S.NaN == S.NaN is
True (indeed, S.NaN is S.NaN is True, since it's singletonized).
Should we have S.NaN == Float('nan') be True (assuming we choose the
first option; obviously it would be if we choose the second one)?  And
how about float('nan') == Float('nan') or float('nan') == S.NaN?

I've also added the SymPy list to this discussion, since this is more
of a problem there than here, though I am interested in your opinion,
as you know more about these floating point things than I do (and
probably most people on the SymPy list).

Aaron Meurer


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »