
I've received the following comments concerning another potential use case for PEP 335. -------- Original Message -------- Subject: PEP 335 and NumPy NA Date: Tue, 4 Oct 2011 15:42:50 -0700 From: Mark Wiebe <mwwiebe@gmail.com> To: Gregory Ewing <greg@cosc.canterbury.ac.nz> Hi Greg, I took a glance at the python-ideas list, and saw that you're proposing an update to PEP 335. I recently did a short internship at Enthought where they asked me to look into the "missing data" problem for NumPy, and I believe the work from that provides further motivation for the PEP. Basically, the approach to allow good handling of missing data is emulating the R programming language by introducing a new value called NA, similar to the built-in None. For an NA with a boolean type, you get a three-valued logic, as described in http://en.wikipedia.org/wiki/Three-valued_logic#Kleene_logic. In the NA I added to NumPy, this truth table cannot be satisfied because of the issue PEP 335 addresses: >>> import numpy as np >>> if True or np.NA: print "yes" ... yes >>> if np.NA or True: print "yes" ... Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: numpy.NA represents an unknown missing value, so its truth value cannot be determined This can be worked around by using the bitwise operators, as mentioned in the PEP for the array case: >>> if True | np.NA: print "yes" ... yes >>> if np.NA | True: print "yes" ... yes Here are the documents with more information: https://github.com/numpy/numpy/blob/master/doc/source/reference/arrays.maskn... https://github.com/numpy/numpy/blob/master/doc/neps/missing-data.rst Cheers, Mark
participants (1)
-
Greg Ewing