Steven D'Aprano wrote:
The list.index method tests for the item with equality. Since NANs are
mandated to compare unequal to anything, including themselves, index
cannot match them.
This is incorrect. .index() uses identity first, then equality, and
will match the same NaN in a list. The OP
On Thu, Oct 25, 2012 at 9:04 PM, Terry Reedy wrote:
> On 10/25/2012 9:46 PM, mambokn...@gmail.com wrote:
>
> a = [float('nan'), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
> a
>>
>> [nan, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>
> a.index(float('nan'))
>>
>> Traceback (most recent call last):
On Sat, 27 Oct 2012 08:56:16 +0200, Thomas Rachel wrote:
> Am 27.10.2012 06:48 schrieb Dennis Lee Bieber:
>
>> I don't know about the more modern calculators, but at least up
>> through my HP-41CX, HP calculators didn't do (binary) "floating
>> point"... They did a form of BCD with a fixed n
On Thu, 25 Oct 2012 22:04:52 -0400, Terry Reedy wrote:
> Containment of nan in collection is tested by is, not ==.
AFAICT, it isn't specific to NaN. The test used by .index() and "in"
appears to be equivalent to:
def equal(a, b):
return a is b or a == b
IOW, it always checks
Am 27.10.2012 06:48 schrieb Dennis Lee Bieber:
I don't know about the more modern calculators, but at least up
through my HP-41CX, HP calculators didn't do (binary) "floating
point"... They did a form of BCD with a fixed number of significant
/decimal/ digits
Then, what about sqrt(x)**
On Fri, Oct 26, 2012 at 2:40 PM, Steven D'Aprano
wrote:
>> The problem isn't with the associativity, it's with the equality
>> comparison. Replace "x == y" with "abs(x-y)> and all your statements fulfill people's expectations.
>
> O RYLY?
>
> Would you care to tell us which epsilon they should use
On 10/26/2012 12:23 PM, Steven D'Aprano wrote:
On Fri, 26 Oct 2012 04:00:03 -0400, Terry Reedy wrote:
This inconsistency is an intentional decision to
not propagate the insanity of nan != nan to Python collections.
That's a value judgement about NANs which is not shared by everyone.
Quite f
On 10/26/2012 11:26 AM, Steven D'Aprano wrote:
On Fri, 26 Oct 2012 03:54:02 -0400, Terry Reedy wrote:
On 10/25/2012 10:44 PM, Steven D'Aprano wrote:
On Thu, 25 Oct 2012 22:04:52 -0400, Terry Reedy wrote:
It is a consequence of the following, which some people (but not all)
believe is mandate
On Sat, 27 Oct 2012 03:45:46 +1100, Chris Angelico wrote:
> On Sat, Oct 27, 2012 at 3:23 AM, Steven D'Aprano
> wrote:
>> In real life, you are *much* more likely to run into these examples of
>> "insanity" of floats than to be troubled by NANs:
>>
>> - associativity of addition is lost
>> - distr
On Sat, Oct 27, 2012 at 3:23 AM, Steven D'Aprano
wrote:
> In real life, you are *much* more likely to run into these examples of
> "insanity" of floats than to be troubled by NANs:
>
> - associativity of addition is lost
> - distributivity of multiplication is lost
> - commutativity of addition is
On 2012-10-26 17:23, Steven D'Aprano wrote:
On Fri, 26 Oct 2012 04:00:03 -0400, Terry Reedy wrote:
On 10/25/2012 10:19 PM, MRAB wrote:
In summary, .index() looks for an item which is equal to its argument,
but it's a feature of NaN (as defined by the standard) that it doesn't
equal NaN, ther
On Fri, 26 Oct 2012 04:00:03 -0400, Terry Reedy wrote:
> On 10/25/2012 10:19 PM, MRAB wrote:
>> In summary, .index() looks for an item which is equal to its argument,
>> but it's a feature of NaN (as defined by the standard) that it doesn't
>> equal NaN, therefore .index() will never find it.
>
On Fri, 26 Oct 2012 03:54:02 -0400, Terry Reedy wrote:
> On 10/25/2012 10:44 PM, Steven D'Aprano wrote:
>> On Thu, 25 Oct 2012 22:04:52 -0400, Terry Reedy wrote:
>>
>>> It is a consequence of the following, which some people (but not all)
>>> believe is mandated by the IEEE standard.
>>>
>>> >>>
On 10/25/2012 10:19 PM, MRAB wrote:
On 2012-10-26 03:04, Terry Reedy wrote:
On 10/25/2012 9:46 PM, mambokn...@gmail.com wrote:
a = [float('nan'), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
a
[nan, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
a.index(float('nan'))
This is a second nan object, and it is not in t
On 10/25/2012 10:44 PM, Steven D'Aprano wrote:
On Thu, 25 Oct 2012 22:04:52 -0400, Terry Reedy wrote:
It is a consequence of the following, which some people (but not all)
believe is mandated by the IEEE standard.
>>> nan = float('nan')
>>> nan is nan
True
The IEEE 754 standard says noth
On 25Oct2012 22:04, Terry Reedy wrote:
| Containment of nan in collection is tested by is, not ==.
| >>> nan = float('nan')
| >>> nan2 = float('nan')
| >>> nan2 is nan
| False
This argues otherwise, and for use of math.isnan() instead.
I expect you were making the point that another NaN is di
On Thu, 25 Oct 2012 22:04:52 -0400, Terry Reedy wrote:
> It is a consequence of the following, which some people (but not all)
> believe is mandated by the IEEE standard.
>
> >>> nan = float('nan')
> >>> nan is nan
> True
The IEEE 754 standard says nothing about object identity. It only
discu
On Thu, 25 Oct 2012 18:46:20 -0700, mamboknave wrote:
> That means, the function .index() cannot detect nan values. It happens
> on both Python 2.6 and Python 3.1
>
> Is this a bug? Or I am not using .index() correctly?
You shouldn't be using index() or == to detect NANs. The right way to
detec
On Thursday, October 25, 2012 7:16:02 PM UTC-7, Cameron Simpson wrote:
Of course!! How could I get into that trap??
Thanks to you & to Terry
--
http://mail.python.org/mailman/listinfo/python-list
On 2012-10-26 03:04, Terry Reedy wrote:
On 10/25/2012 9:46 PM, mambokn...@gmail.com wrote:
a = [float('nan'), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
a
[nan, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
a.index(float('nan'))
Traceback (most recent call last):
File "", line 1, in
ValueError: list.index(x):
On 25Oct2012 18:46, mambokn...@gmail.com wrote:
| >>> a = [float('nan'), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
| >>> a
| [nan, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
| >>> a.index(float('nan'))
| Traceback (most recent call last):
| File "", line 1, in
| ValueError: list.index(x): x not in list
|
| Tha
On 10/25/2012 9:46 PM, mambokn...@gmail.com wrote:
a = [float('nan'), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
a
[nan, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
a.index(float('nan'))
Traceback (most recent call last):
File "", line 1, in
ValueError: list.index(x): x not in list
That means, the function
>>> a = [float('nan'), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> a
[nan, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> a.index(float('nan'))
Traceback (most recent call last):
File "", line 1, in
ValueError: list.index(x): x not in list
That means, the function .index() cannot detect nan values.
It happens
23 matches
Mail list logo