Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #83524

Re: Can numpy do better than this?

From Nobody <nobody@nowhere.invalid>
Newsgroups comp.lang.python
Subject Re: Can numpy do better than this?
Date 2015-01-11 04:12 +0000
Organization A noiseless patient Spider
Message-ID <pan.2015.01.11.04.12.53.470000@nowhere.invalid> (permalink)
References <71ecb9ec-5d8c-4503-a75b-1d4aeca79b08@googlegroups.com>

Show all headers | View raw


On Thu, 08 Jan 2015 09:56:50 -0800, Rustom Mody wrote:

> Given a matrix I want to shift the 1st column 0 (ie leave as is) 2nd by
> one place, 3rd by 2 places etc.
> 
> This code works.
> But I wonder if numpy can do it shorter and simpler.

def shiftcols(mat):
    iy,ix = np.indices(mat.shape)
    return mat[(iy+ix)%mat.shape[0],ix]

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Can numpy do better than this? Rustom Mody <rustompmody@gmail.com> - 2015-01-08 09:56 -0800
  Re: Can numpy do better than this? Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-08 12:27 -0700
    Re: Can numpy do better than this? Rustom Mody <rustompmody@gmail.com> - 2015-01-08 17:13 -0800
      Re: Can numpy do better than this? Rustom Mody <rustompmody@gmail.com> - 2015-01-08 17:19 -0800
      Re: Can numpy do better than this? Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-08 18:36 -0700
        Re: Can numpy do better than this? Rustom Mody <rustompmody@gmail.com> - 2015-01-08 17:45 -0800
  Re: Can numpy do better than this? Nobody <nobody@nowhere.invalid> - 2015-01-11 04:12 +0000

csiph-web