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] = 1 do not work. So is the way to do this
> simply to run a separate statement in the form b[condition]= 1 for each
> test?

For this, you have to use the binary operators instead of logical ones. For 
example:

In [43]: a=numpy.arange(10)

In [44]: b=numpy.arange(10)

In [45]: b[(a < 2) | (a > 8)] = 1

In [46]: b
Out[46]: array([1, 1, 2, 3, 4, 5, 6, 7, 8, 1])

[be sure to use parentesizes appropriately]

Cheers,

-- 
>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 "-"

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to