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

Kurt Smith kwmsmith@gmail....
Tue Aug 28 01:26:42 CDT 2007


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


More information about the SciPy-user mailing list