[Nipy-devel] nipy affines

Fernando Perez fperez.net@gmail....
Tue Jan 12 14:49:40 CST 2010


Howdy,

On Tue, Jan 12, 2010 at 9:45 AM, Jonathan Taylor
<jonathan.taylor@stanford.edu> wrote:
> This little change fixes the Ellipsis problem...
>
> === modified file 'nipy/core/reference/array_coords.py'
> --- nipy/core/reference/array_coords.py 2009-02-25 04:54:32 +0000
> +++ nipy/core/reference/array_coords.py 2010-01-12 18:00:40 +0000
> @@ -94,6 +94,13 @@
>
>          if type(index) != type(()):
>              index = (index,)
> +        if Ellipsis in index:
> +            if np.sum([i == Ellipsis for i in index]) > 1:

Minor note, no need to use np.sum() here, the builtin sum() suffices
and is over 10 times faster:

In [6]: timeit sum([i == Ellipsis for i in index])
100000 loops, best of 3: 2.62 us per loop

In [7]: timeit np.sum([i == Ellipsis for i in index])
10000 loops, best of 3: 30.3 us per loop


Cheers,

f



More information about the Nipy-devel mailing list