Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #109029
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Michael Selik <michael.selik@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: numpy problem |
| Date | Mon, 23 May 2016 23:00:30 +0000 |
| Lines | 25 |
| Message-ID | <mailman.37.1464044443.20402.python-list@python.org> (permalink) |
| References | <46F1751E-CA1E-4AB3-B6EB-589E1E2FD1D9@onemanifest.net> <nhusgg$vna$1@ger.gmane.org> <17D9C96A-C4EB-426F-A4A7-AA6492D7DBAB@onemanifest.net> <CAGgTfkPR2FMuKW6j5DrowYT5ML4prG8z1=8qhhviW4Z-K8WkoQ@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de F1iiwryT3MQ5idG8dCGYbweX0E5EEf08OTuVy8ZIIp9g== |
| Return-Path | <michael.selik@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'column': 0.07; 'indexes': 0.09; 'rows': 0.09; 'index': 0.13; '2016': 0.16; '23,': 0.16; 'fancy': 0.16; 'keep,': 0.16; 'necessary).': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'row': 0.16; 'values:': 0.16; 'wrote:': 0.16; '>': 0.18; 'to:2**1': 0.21; 'subject:problem': 0.22; 'seems': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; "i've": 0.25; 'to:no real name:2**1': 0.27; 'message- id:@mail.gmail.com': 0.27; 'selecting': 0.29; 'array': 0.29; 'getting': 0.33; 'gives': 0.35; 'received:google.com': 0.35; 'so,': 0.35; 'should': 0.36; 'received:209.85': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'skip:v 20': 0.38; 'received:209': 0.38; 'received:209.85.220': 0.38; 'to:addr:python.org': 0.40; 'skip:n 10': 0.62; '81,': 0.84; 'otten': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=Bpu07C1/yl2uDDzi4VNl21ha3g+iwBsXn05EXWSk09w=; b=R5ZsxY1rdV8V0G3dXMdsg1ZZ/MHyRwXPztkM4SR3FEqEDmMlW5Jb/mLFTzqEjXSlEn Li5kWVzG1AYKkAERtLGwCtMk+bZPp94HA3sW3JFKbT2gs39lckGfj0aTZW+WaE2s7how ESUl2E1FoZLSgE6i097X9skJGxsd7wP4zqsbCP4JFSemp720uEt1GCUgEz5bX4/H6dCe VT1qtwcySNnjJHaSveA/2Zffh/+z6s8uCTUSif0MbtpgG+tqN2B8Yes+FlnVKg9tSiLF QXhnwMUumb6AwTrYr38UEl1ZxC2JaYLGnukjatgBuk3ryRUDxmf2yPmyOQ8R90gxUH8Y rPPw== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=Bpu07C1/yl2uDDzi4VNl21ha3g+iwBsXn05EXWSk09w=; b=a9qOeUgriEy0BqOB6ozPPT7vbSK3ADgOMfdFAGpFZVLVdzhHeaafGSsE81iP9WjZpi XUGQfSdICca06lt6nENpwVP1lCe8NDnOBOJsWnbacHdjsSjwV6cU8ue1Obc1iPC1XGn4 uragFsNUER8KBOrRo9eLbmsmWtUCsm9X/FJBAnwdxYC30EQMd3DFXTdO2IY0j1l0RgaQ m54xgJQPHzqfxL5QbrqTHozfjh4A9dAB8QUGtYBXOFIHCPB/ALJ4IagYNU0+LC1Basec a3YjAZRrBD7KkFVdqGsqTFdFk9twnDxnUSTKbhMAVOt9fl/FM8jQqb6cfTZ9tZzLa5wI u43w== |
| X-Gm-Message-State | ALyK8tJhnAFzv20IxBaVAre41y6elHnXUvFCVNt/WuDrwl68mbLd7kkO9SipkQ7+g0Y8u3I4sodCqejJ31Zbew== |
| X-Received | by 10.55.163.215 with SMTP id m206mr645746qke.96.1464044440108; Mon, 23 May 2016 16:00:40 -0700 (PDT) |
| In-Reply-To | <17D9C96A-C4EB-426F-A4A7-AA6492D7DBAB@onemanifest.net> |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.22 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <CAGgTfkPR2FMuKW6j5DrowYT5ML4prG8z1=8qhhviW4Z-K8WkoQ@mail.gmail.com> |
| X-Mailman-Original-References | <46F1751E-CA1E-4AB3-B6EB-589E1E2FD1D9@onemanifest.net> <nhusgg$vna$1@ger.gmane.org> <17D9C96A-C4EB-426F-A4A7-AA6492D7DBAB@onemanifest.net> |
| Xref | csiph.com comp.lang.python:109029 |
Show key headers only | View raw
On Mon, May 23, 2016 at 9:12 AM <lists@onemanifest.net> wrote: > > On 23 mei 2016, at 14:19, Peter Otten <__peter__@web.de> wrote: > > lists@onemanifest.net wrote: > > > >> I've got a 2D array > >> And an array of indexes that for shows which row to keep for each column > >> of values: > >> > >> keep = np.array([2, 3, 1, 9, 2]) > >> > >> So, the result should be an array like array([ values[2,0], values[3,1], > >> values[1,2], values[9,3], values[2,4] ]) == np.array([92, 62, 38, 81, > 44]) > >> > > values[keep].diagonal() > > That seems to do the trick! > To clarify, the fancy index is selecting all rows you want to keep, which gives you a 5x5 array (repeating rows if necessary). Then you are getting the diagonal of that selection. If that was already clear, my apologies for the noise.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: numpy problem Michael Selik <michael.selik@gmail.com> - 2016-05-23 23:00 +0000
csiph-web