faster Array.take( floatindices.astype(int) ) ?
Folks, is there a way to speed up Array.take( floatindices.astype(int) ) ? astype(int) makes a copy, floor() returns floats. (Is there a wiki of NumPy oneliners / various tricks ? would sure beat googling.) Thanks, cheers  denis
On Fri, Feb 1, 2013 at 6:24 AM, denis
Folks, is there a way to speed up Array.take( floatindices.astype(int) ) ? astype(int) makes a copy, floor() returns floats.
(Is there a wiki of NumPy oneliners / various tricks ? would sure beat googling.)
You can use floats for the indices in the take method, they are floored before use. That said, the Fortran FLOOR function returns integers and it would be useful if numpy had integer versions of floor, ceil, divmod, say, ifloor, iceil, idivmod that raised errors if the resulting integers overflowed. Chuck
Charles R Harris
You can use floats for the indices in the take method, they are floored before use.
Chuck, that's in 1.7 ? In 1.6.2 x = np.arange(10) x.take([3.14]) array([3]) x.take(np.array([3.14])) TypeError: array cannot be safely cast to required type cheers  denis
participants (2)

Charles R Harris

denis