Went ahead and added an enhancement request:
http://projects.scipy.org/scipy/numpy/ticket/293

This is something I've wanted in the past too.

--bb

On 9/25/06, Charles R Harris <[EMAIL PROTECTED]> wrote:
>
>
> On 9/24/06, Bill Baxter <[EMAIL PROTECTED]> wrote:
> > Howdy Angus,
> > Yeh, that does seem like a hole in the API.  Travis added a rollaxis()
> > but there's still no simple way to roll the elements themselves.
> >
> > I took a look at numpy.fft.fftshift, which is a function that has to
> > do a similar thing.  It does it by concatenating aranges and then
> > doing a take().  Presumably Pearu knew what he was doing when he wrote
> > that, so we can assume this is probably close to the best possible.
> > :-)  From that idea here's a function that implements roll().
> >
> > def roll(y,shift,axis):
> >     """Roll the elements in the array by 'shift' positions along the
> > given axis."""
> >     from numpy import asanyarray,concatenate,arange
> >     y = asanyarray(y)
> >     n = y.shape[axis]
> >     shift %= n # does the right thing for negative shifts, too
> >     return
> y.take(concatenate((arange(shift,n),arange(shift))), axis)
>
> It is possible to do a shift inplace using two reflections implemented with
> swaps.  This works because two reflections is the same as a rotating twice
> the distance between the centers of the reflections. I don't know if it is
> worth implementing this, however.
>
> Chuck

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to