On Wed, March 11, 2009 7:50 am, Christopher Barker wrote:
Python does not distinguish between True and
False -- Python makes the distinction between something and nothing.
In that context, NaN is nothing, thus False.
Mathematically speaking, NaN is a quantity with undefined value.
Charles R Harris wrote:
It isn't 0 so it should be True. Any disagreement?... Chuck
NaN is not a number equal to 0, so it should be True?
NaN is not a number different from 0, so it should be False?
Also see Pearu's comment.
Why not raise an exception when NaN is evaluated in a boolean
Charles R Harris wrote:
#include math.h
#include stdio.h
int main() {
double nan = sqrt(-1);
printf(%f\n, nan);
printf(%i\n, bool(nan));
return 0;
}
$ ./nan
nan
1
So resolved, it is True.
Unless specified in the ISO C
Sturla Molden wrote:
Charles R Harris wrote:
#include math.h
#include stdio.h
int main() {
double nan = sqrt(-1);
printf(%f\n, nan);
printf(%i\n, bool(nan));
return 0;
}
$ ./nan
nan
1
So resolved, it is True.
--- On Wed, 3/11/09, Bruce Southey bsout...@gmail.com wrote:
From: Bruce Southey bsout...@gmail.com
Subject: Re: [Numpy-discussion] What is the logical value of nan?
To: Discussion of Numerical Python numpy-discussion@scipy.org
Date: Wednesday, March 11, 2009, 10:24 AM
This is one link
On Wed, Mar 11, 2009 at 8:24 AM, Bruce Southey bsout...@gmail.com wrote:
Sturla Molden wrote:
Charles R Harris wrote:
#include math.h
#include stdio.h
int main() {
double nan = sqrt(-1);
printf(%f\n, nan);
printf(%i\n, bool(nan));
Sturla Molden wrote:
Why not raise an exception when NaN is evaluated in a boolean
context? bool(NaN) has no obvious interpretation, so it should be
considered an error.
+1
Though there is clearly a lot of legacy around this, so maybe it's best
to follow C convention (sigh).
Bruce Southey
On Wed, Mar 11, 2009 at 11:06 AM, Christopher Barker
chris.bar...@noaa.govwrote:
Sturla Molden wrote:
Why not raise an exception when NaN is evaluated in a boolean
context? bool(NaN) has no obvious interpretation, so it should be
considered an error.
+1
Though there is clearly a lot of
Charles R Harris wrote:
Raising exceptions in ufuncs is going to take some work as the inner
loops are void functions without any means of indicating an error.
Exceptions also need to be thread safe. So I am not opposed but it is
something for the future.
I just saw David Cournapeau's
On Wed, Mar 11, 2009 at 12:19 PM, Sturla Molden stu...@molden.no wrote:
Charles R Harris wrote:
Raising exceptions in ufuncs is going to take some work as the inner
loops are void functions without any means of indicating an error.
Exceptions also need to be thread safe. So I am not
On Thu, Mar 12, 2009 at 3:36 AM, Charles R Harris
charlesr.har...@gmail.com wrote:
On Wed, Mar 11, 2009 at 12:19 PM, Sturla Molden stu...@molden.no wrote:
Charles R Harris wrote:
Raising exceptions in ufuncs is going to take some work as the inner
loops are void functions without any
I think it should be considered as roughly (the numerical) equivalent to None,
therefore False
Nadav.
-הודעה מקורית-
מאת: numpy-discussion-boun...@scipy.org בשם Charles R Harris
נשלח: ג 10-מרץ-09 21:08
אל: numpy-discussion
נושא: [Numpy-discussion] What is the logical value of nan?
Tue, 10 Mar 2009 13:08:17 -0600, Charles R Harris wrote:
It isn't 0 so it should be True. Any disagreement?
+1
Nonzero Python object, hence True. Moreover, it's also True in Python:
import numpy as np
type(np.nan)
type 'float'
bool(np.nan)
True
IMHO, we should follow Python here, otherwise
2009/3/10 Pauli Virtanen p...@iki.fi:
Nonzero Python object, hence True. Moreover, it's also True in Python:
Also in C:
#include math.h
#include stdio.h
int main() {
double nan = sqrt(-1);
printf(%f\n, nan);
printf(%i\n, bool(nan));
return 0;
}
$ ./nan
nan
1
Cheers
Stéfan
On Tue, Mar 10, 2009 at 2:49 PM, Charles R Harris charlesr.har...@gmail.com
wrote:
On Tue, Mar 10, 2009 at 3:16 PM, Stéfan van der Walt ste...@sun.ac.zawrote:
2009/3/10 Pauli Virtanen p...@iki.fi:
Nonzero Python object, hence True. Moreover, it's also True in Python:
Also in C:
On Tue, Mar 10, 2009 at 4:19 PM, Timothy Hochberg tim.hochb...@ieee.orgwrote:
On Tue, Mar 10, 2009 at 2:49 PM, Charles R Harris
charlesr.har...@gmail.com wrote:
On Tue, Mar 10, 2009 at 3:16 PM, Stéfan van der Walt ste...@sun.ac.zawrote:
2009/3/10 Pauli Virtanen p...@iki.fi:
Nonzero
Charles R Harris wrote:
On Tue, Mar 10, 2009 at 4:19 PM, Timothy Hochberg
tim.hochb...@ieee.org mailto:tim.hochb...@ieee.org wrote:
On Tue, Mar 10, 2009 at 2:49 PM, Charles R Harris
charlesr.har...@gmail.com mailto:charlesr.har...@gmail.com wrote:
On Tue, Mar 10, 2009
Pauli Virtanen wrote:
Tue, 10 Mar 2009 13:08:17 -0600, Charles R Harris wrote:
It isn't 0 so it should be True. Any disagreement?
- 1
Nonzero Python object, hence True.
Empty sequences are False also. There was a lot of discussion about all
this when Guido added Bool types to python.
18 matches
Mail list logo