[SciPy-user] really basic where() function question

Michael Hearne mhearne@usgs....
Mon Aug 27 22:23:29 CDT 2007

I'm trying to put together a presentation at work on Python, and I'm  
confused about the where() numpy function.

The documentation, which is scant, indicates that where() requires  
three input arguments:

where(condition,x,y) returns an array shaped like condition and has  
elements of x and y where condition is respectively true or false

First, I have to admit that I don't understand what x and y are for  

Second, I want to use where() like find() in Matlab - namely:
a = array([3,5,7,9])
i = where(a <= 6) => should return (array([0, 1]),) (see http:// 

instead, I get this error:
<type 'exceptions.TypeError'>             Traceback (most recent call  

/Users/mhearne/scipy/<ipython console> in <module>()

<type 'exceptions.TypeError'>: where() takes exactly 3 arguments (1  

What am I doing wrong?  Or did the usage of where() change since the  
cookbook example was written?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20070827/bf2f3671/attachment.html 

More information about the SciPy-user mailing list