[SciPy-user] SciPy-user Digest, Vol 31, Issue 42

Pierre GM pgmdevlist at mailcan.com
Thu Mar 30 20:23:06 CST 2006


Salut,
A couple of comments:
> #####################################
> lionel[donn?es]21>from scipy import *
> lionel[donn?es]22>from numpy import ma as MA
> lionel[donn?es]23>test=MA.masked_object([1,2,3,4,nan,6], nan)
> lionel[donn?es]24>print amin(test), amax(test), mean(test)

It's a very bad idea to use nan as a masking value, as (nan == nan) is always 
False. The mask construction will fail, and you won't have any value actually 
masked. You can use `inf` instead, that seems to work. 

> lionel[donn?es]26>print amin(test), amax(test), mean(test)
> 1.0 6.0 3.2

Try to use methods instead of functions. It should simplify your code and make 
it a bit more foolproof.

A good part of scipy (a bit less of numpy) is not adapted to MaskedArrays. If 
you run into problems, please update the MaskedArray page of the wiki.
A plus



More information about the SciPy-user mailing list