Marcus von Appen wrote:
On, Sun Jan 06, 2008, Lenard Lindstrom wrote:
[snip]
The code is also inefficient, not making proper use to numpy's type system. Using (numpy.uint8(0xff), numpy.uint8(0)) as the second argument to choose returns an array of uint8.I do not know anything about the efficiency tweaks in numpy as the available documentation lacks such things. I'd have expected it to match the type automatically, but for now I changed the function using your proposal. Thanks. Regards Marcus
I admit I made an assumption about efficiency. But I don't see how removing the "array = array.astype (numpy.uint8)" step, where an array of int32 is copied to a newly allocated array of uint8, will make things worse.
-- Lenard Lindstrom <len-l@xxxxxxxxx>