[SciPy-user] where bug

Travis Oliphant oliphant.travis at ieee.org
Tue Oct 10 02:55:37 EDT 2006


Ryan Krauss wrote:
> I am having a problem running some slightly older code under a fairly
> new Scipy for the first time.  The code uses where and something like
> this:
> In [23]: t=arange(0,1,0.01)
>
> In [24]: where(t>0.5)
> Out[24]:
> (array([51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
>        68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
>        85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]),)
>
> used to return just the array instead of the tuple with the array in
> it.  Is this a feature or a bug? 
It's a feature (the old behavior was a bug...).  The functionality of 
where is actually from NumPy and has changed to be consistent with 
Numarray.    You can get the old behavior with flatnonzero(...) or of 
course where(...)[0].

-Travis




More information about the SciPy-User mailing list