[Numpy-discussion] Missing/accumulating data
Christopher Barker
Chris.Barker at noaa.gov
Tue Jul 5 16:02:36 EDT 2011
Mark Wiebe wrote:
> Speaking of which, would we make the NA value be false?
>
> For booleans, it works out like this:
>
> http://en.wikipedia.org/wiki/Ternary_logic#Kleene_logic
That's pretty cool!
> In R, trying to test the truth value of NA ("if (NA) ...") raises an
> exception. Adopting this behavior seems reasonable to me.
I'm not so sure. the other president is Python, where None is
interpreted as False.
In general, in non-numpy code, I use None to mean "not set yet" or "I'm
not sure", or, whatever. It's pretty useful to have it be false.
However, I also do:
if x is not None:
rather than-
if x:
so as to be unambiguous about what I'm testing for (and because if x ==
0, I don't want the test to fail), so I guess:
if arr[i] is np.NA:
would be perfectly analogous.
-Chris
> -Mark
>
>
>
> -Chris
>
>
> --
> Christopher Barker, Ph.D.
> Oceanographer
>
> Emergency Response Division
> NOAA/NOS/OR&R (206) 526-6959 <tel:%28206%29%20526-6959>
> voice
> 7600 Sand Point Way NE (206) 526-6329 <tel:%28206%29%20526-6329> fax
> Seattle, WA 98115 (206) 526-6317 <tel:%28206%29%20526-6317>
> main reception
>
> Chris.Barker at noaa.gov <mailto:Chris.Barker at noaa.gov>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org <mailto:NumPy-Discussion at scipy.org>
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the NumPy-Discussion
mailing list