A Divendres 06 Octubre 2006 15:30, Vikalpa Jetly va escriure:
> avoid the memory error. Related question is that I need to test for
> multiple conditions on the same array and set values to 1 or 0. I see that
> statements like b[a>200 or a<50] =3D 1 do not work. So is the way to do t=
his
> simply to run a separate statement in the form b[condition]=3D 1 for each
> test?
=46or this, you have to use the binary operators instead of logical ones. F=
or=20
example:
In [43]: a=3Dnumpy.arange(10)
In [44]: b=3Dnumpy.arange(10)
In [45]: b[(a < 2) | (a > 8)] =3D 1
In [46]: b
Out[46]: array([1, 1, 2, 3, 4, 5, 6, 7, 8, 1])
[be sure to use parentesizes appropriately]
Cheers,
=2D-=20
>0,0< Francesc Altet =A0 =A0 http://www.carabos.com/
V V C=E1rabos Coop. V. =A0=A0Enjoy Data
"-"
|