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


Groups > comp.lang.python > #37856

Re: numpy array operation

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; '2],': 0.16; '3],': 0.16; '[2,': 0.16; 'numpy': 0.16; 'received:80.91.229.3': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-dialin.net': 0.16; 'subject:array': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.28; 'to:addr:python-list': 0.33; 'there': 0.35; 'received:org': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'skip:a 30': 0.60
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: numpy array operation
Date Tue, 29 Jan 2013 10:28:02 +0100
Organization None
References <f94d7654-2b87-404b-a0b0-76f1ccf8ee6c@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p50849864.dip.t-dialin.net
User-Agent KNode/4.7.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1167.1359451658.2939.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1359451658 news.xs4all.nl 6921 [2001:888:2000:d::a6]:33013
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:37856

Show key headers only | View raw


C. Ng wrote:

> Is there a numpy operation that does the following to the array?
> 
> 1 2  ==>  4 3
> 3 4       2 1

How about

>>> a
array([[1, 2],
       [3, 4]])
>>> a[::-1].transpose()[::-1].transpose()
array([[4, 3],
       [2, 1]])

Or did you mean

>>> a.reshape((4,))[::-1].reshape((2,2))
array([[4, 3],
       [2, 1]])

Or even

>>> -a + 5
array([[4, 3],
       [2, 1]])

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


Thread

numpy array operation "C. Ng" <ngcbmy@gmail.com> - 2013-01-29 00:41 -0800
  Re: numpy array operation Peter Otten <__peter__@web.de> - 2013-01-29 10:28 +0100
  Re: numpy array operation Tim Williams <tjandacw@cox.net> - 2013-01-29 04:59 -0800
  Re: numpy array operation Alok Singhal <as8ca@virginia.edu> - 2013-01-29 18:49 +0000
    Re: numpy array operation Terry Reedy <tjreedy@udel.edu> - 2013-01-29 15:05 -0500

csiph-web