[Nipy-devel] nipy affines

Matthew Brett matthew.brett@gmail....
Tue Jan 12 14:38:08 CST 2010


Hi,

On Tue, Jan 12, 2010 at 5:45 PM, 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:
> +                raise ValueError("only one Ellipsis(...) allowed in slice")
> +            first_index = list(index).index(Ellipsis)
> +            last_index = len(self.shape) - (len(index) - first_index - 1)
> +            index = (index[:first_index] + (last_index-first_index)*
> +                     (slice(None),) + index[(first_index+1):])
>          return _slice(self.coordmap, self.shape, *index)

Oh - thanks - nice,

Matthew



More information about the Nipy-devel mailing list