Thanks Travis and Robert. I am just getting my feet wet in numpy. Both
approaches i.e:

b = zeros_like(a)
b[a>200] = 1

or

b = (a > 200).astype(numpy.uint8)

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?

Also since my output has to be a binary array, can the new array be defined
as binary type or nibble, potentially reducing memory overhead?

Thanks.
Vikalpa


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Travis
Oliphant
Sent: Thursday, October 05, 2006 5:44 PM
To: Discussion of Numerical Python
Subject: Re: [Numpy-discussion] Memory errors

>
The MemoryError is a direct result when system malloc fails.    Rather 
than use where with two scalars (you're resulting array will be int32 
and therefore 4-times larger).

Use

b = zeros_like(a)
b[a>200] = 1

which will consume less memory.

-Travis
 

-------------------------------------------------------------------------
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



-------------------------------------------------------------------------
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