[Numpy-discussion] NaNs and infs

Tim Churches tchur at optushome.com.au
Sun Nov 9 11:26:17 CST 2003


On Mon, 2003-11-10 at 04:53, Alexander Schmolck wrote:
> Typically when NaNs/infs occur in my arrays something is going wrong, so
> ideally I'd like an exception to be raised when that happens. Failing that I'd
> like to have some robust (across python and Numeric/numarray versions) way of
> testing wether an array contains NaNs or inifinities. I'd be happy as long as
> this works on my particular platform (linux/intel).
> 
> At the moment I don't have much of a clue how to achieve this, which can be
> pretty annoying (IIRC neither python nor Numeric is commited to any support of
> NaN values; python comes with the optional fpectl module, which apparently is
> however unmaintained, and generally deemed unsuitable for almost anything
> -- not that I even manged to build it. Also NaN behavior doesn't seem
> consistent across python scalars and Numeric arrays and different python
> version (again IIRC)).
> 
> Any suggestions? How are other people dealing with these issues?

Increasingly we are turning to R (http://www.r-project.org) because it
provides fully integrated support for Inf, NaN and NA (missing) in all
its data structures, including matrices and higher-rank arrays, viz:

> 2/0
[1] Inf
> 0/0
[1] NaN
> NA/1
[1] NA

R can be embedded in Python and passed NumPy arrays or other data
structures via Walter Moriera's excellent RPy modules (see
http;//rpy.sf.net).

However, the fundamental problem is that support for NA (missing), Inf
and NaN seems to be afterthoughts in both NumPy and numarray, whereas
such support should have been integrated into the design right from the
outset.

Is it too late to incorporate them into the fabric of numarray?

-- 

Tim C

PGP/GnuPG Key 1024D/EAF993D0 available from keyservers everywhere
or at http://members.optushome.com.au/tchur/pubkey.asc
Key fingerprint = 8C22 BF76 33BA B3B5 1D5B  EB37 7891 46A9 EAF9 93D0


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20031109/15c597cb/attachment.bin 


More information about the Numpy-discussion mailing list