slicing using Index and Mask arrays
![](https://secure.gravatar.com/avatar/4d021a1d1319f36ad861ebef0eb5ba44.jpg?s=120&d=mm&r=g)
I have just added a feature to scipy in CVS This feature lets a[a > 3] = 10 a[indexarray] = 3 and so forth to function. Currently a[maskarray] and a[indexarray] always return a 1-d array (multidimensional returns not yet supported) while a[maskarray] = obj and a[indexarray]= obj will keep the shape of a To enable the new feature you must type (we will do this by default on scipy import at some point) scipy.alter_numeric() You can get back old numeric behavior using scipy.restore_numeric() Please report any bugs you find... -Travis O.
![](https://secure.gravatar.com/avatar/5a7d8a4d756bb1f1b2ea729a7e5dcbce.jpg?s=120&d=mm&r=g)
Travis Oliphant wrote:
I have just added a feature to scipy in CVS
This feature lets
a[a > 3] = 10 a[indexarray] = 3
and so forth to function.
So far so good! This is a great addition, this message is just to report that it works here with current CVS, Numeric 23.1 built with dotblas on, and a binary ATLAS as supplied by scipy.org: planck[~]> scipy IPython profile: scipy Welcome to the SciPy Scientific Computing Environment. In [1]: a=arange(10) In [2]: a[a>3]=9 --------------------------------------------------------------------------- IndexError Traceback (most recent call last) /home/fperez/<console> IndexError: invalid index In [3]: scipy.alter_numeric() In [4]: a[a>3]=9 In [5]: a Out[5]: NumPy array, format: long [0 1 2 3 9 9 9 9 9 9] In [6]: scipy.restore_numeric() In [7]: a[a>3]=9 --------------------------------------------------------------------------- IndexError Traceback (most recent call last) /home/fperez/<console> IndexError: invalid index I'll enable the alter_numeric() from now on permanently for me. Many thanks! f.
participants (2)
-
Fernando Perez
-
Travis Oliphant