[SciPy-User] From 1-D boolean array to integer index

Jacob Biesinger jake.biesinger@gmail....
Tue Oct 11 21:00:48 CDT 2011


On Tue, Oct 11, 2011 at 2:19 PM, Oleksandr Huziy <guziy.sasha@gmail.com>wrote:

> Try shifting before the loop in the Alok's suggestion.
>

Thanks for the catch-- it's a bit faster:

bit_shift = 1 << sp.arange(size-1, -1, -1)
%timeit sp.sum((bit_shift)[data])
100000 loops, best of 3: 4.06 us per loop

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20111011/a73be774/attachment.html 


More information about the SciPy-User mailing list