Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Manolo =?iso-8859-1?Q?Mart=EDnez?= Newsgroups: comp.lang.python Subject: Re: 4D arrays Date: Wed, 2 Dec 2015 10:17:17 +0100 Lines: 19 Message-ID: References: <08275b89237d46ae87ff574db3748dc2@cptec.inpe.br> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.uni-berlin.de i9pilpjyAJOAFZMYcVeS2gxrsYf9TCPHOCyHR4hfTyaQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.093 X-Spam-Evidence: '*H*': 0.83; '*S*': 0.02; '2],': 0.16; '55,': 0.16; '57,': 0.16; '58,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'row': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'second': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'example': 0.26; 'equivalent': 0.27; 'extract': 0.33; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'to:addr:python.org': 0.40; 'different': 0.63; '71,': 0.84; '92,': 0.84; 'clearer': 0.84; 'otten': 0.84; 'received:82.223': 0.84 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:99852 On 12/01/15 at 06:47pm, Peter Otten wrote: > Extract 2D arrays: > > >>> a[:,2,3] > array([[ 55, 56, 57, 58, 59], > [115, 116, 117, 118, 119]]) > >>> a[1,:,2] > array([[ 70, 71, 72, 73, 74], > [ 90, 91, 92, 93, 94], > [110, 111, 112, 113, 114]]) The first one is equivalent to a[:, 2, 3, :], which is perhaps clearer in this context: you are singling out row 2 in axis 1, and row 3 in axis 2, and taking everything from axes 0 and 3. Mutatis mutandis with the second example and a[1, :, 2, :], which is different from a[1, :, :, 2], etc. Manolo