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

Michael Hearne mhearne@usgs....
Tue Aug 28 08:21:31 CDT 2007


Kurt got it in one - I was using (without knowing it), the pylab  
version of "where", which I hadn't known existed.

I'm using ipython with the -pylab option, which generally speaking I  
really like.  Are there any other gotcha's like this that users  
should know about?

--Mike
On Aug 28, 2007, at 12:26 AM, Kurt Smith wrote:

> On 8/27/07, Robert Kern <robert.kern@gmail.com> wrote:
>> Michael Hearne wrote:
>>> 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:
>
> The pylab-numpy inconsistency bug strikes again!
>
> There is a pylab "where" that is different from the numpy "where."
>
> import pylab as pl
> import numpy as np
>
> a = np.array([3,5,7,9])
> np.where(a<=6)
> # yields (array([0, 1]),)
> pl.where(a<=6)
> # Traceback (most recent call last):
> #   File "<ipython console>", line 1, in <module>
> # TypeError: where() takes exactly 3 arguments (1 given)
>
> Moral: be careful about importing * from pylab (or running $ ipython
> -pylab)!  Its functions aren't the same as numpy/scipy.
>
> Kurt
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user




------------------------------------------------------
Michael Hearne
mhearne@usgs.gov
(303) 273-8620
USGS National Earthquake Information Center
1711 Illinois St. Golden CO 80401
Senior Software Engineer
Synergetics, Inc.
------------------------------------------------------


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20070828/26669e3a/attachment-0001.html 


More information about the SciPy-user mailing list