Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29571
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.025 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'mrab': 0.05; 'sep': 0.09; 'instead:': 0.16; 'looping': 0.16; 'numpy': 0.16; 'read:': 0.16; 'subject:array': 0.16; 'subject:looping': 0.16; 'wrote:': 0.17; 'thu,': 0.17; 'header:In-Reply-To:1': 0.25; '(which': 0.26; 'expanding': 0.27; 'message-id:@mail.gmail.com': 0.27; 'cat': 0.29; 'probably': 0.29; 'point': 0.31; 'to:addr:python-list': 0.33; 'operations': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'should': 0.36; 'received:209': 0.37; 'far': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'first': 0.61; 'skip:n 10': 0.63; '20,': 0.65; 'subject:dic': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=yOGh5F22wYMWPbExCsohapXdqnzyHxLB6Hn0T7nqE1I=; b=FLbWa57ytuEAp80lZhsgqW9b8iUbI3clOr8/f466tRD/zELL0hck1BUYhy/x0knDtx JfJI0j8FkvQMUIawWdkwIw1hfhrISFNTpQZO9jhgCxAMsZYwG0C9szygAPChjt0d8Cr2 msuHcA6xksWH5KHSVM1YrrVzEFO3ERVgiJnvj3i5+XMDmbQlHP03OuyFGle3LnEMi5W4 w51Ee7o5ZP6KC4dWZip0LP5HJ+wjunIZ0XaU5n4OzvhPzucU0zpiBsCgOe88hxAcUSo9 DSVehJml0bxXtlh3JNmR4Y2WHxMd60W+wBOq58onbhXQseeAF3yHn5reeVLbDGceRzbi NLOQ== |
| MIME-Version | 1.0 |
| In-Reply-To | <CALwzid=HowMzWmgiU2+2Gu4opxWu0Hx-iOFRZZcXi=BAdKVfrw@mail.gmail.com> |
| References | <007b2d71-3355-4085-b84f-204834b2c8d0@googlegroups.com> <505B6A00.10308@mrabarnett.plus.com> <CALwzid=HowMzWmgiU2+2Gu4opxWu0Hx-iOFRZZcXi=BAdKVfrw@mail.gmail.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Thu, 20 Sep 2012 13:29:23 -0600 |
| Subject | Re: looping in array vs looping in a dic |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| 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.971.1348169395.27098.python-list@python.org> (permalink) |
| Lines | 14 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1348169395 news.xs4all.nl 6944 [2001:888:2000:d::a6]:39204 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:29571 |
Show key headers only | View raw
On Thu, Sep 20, 2012 at 1:28 PM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> Expanding on what MRAB wrote, since you probably have far fewer
> categories than pixels, you may be able to take better advantage of
> numpy's vectorized operations (which are pretty much the whole point
> of using numpy in the first place) by looping over the categories
> instead:
>
> for cat in categories:
> totals[cat] += np.sum(valuesCategory * (valuesRaster == cat))
Of course, that should have read:
for cat in categories:
totals[cat] += np.sum(valuesRaster * (valuesCategory == cat))
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
looping in array vs looping in a dic giuseppe.amatulli@gmail.com - 2012-09-20 11:31 -0700
Re: looping in array vs looping in a dic MRAB <python@mrabarnett.plus.com> - 2012-09-20 20:09 +0100
Re: looping in array vs looping in a dic Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-20 13:28 -0600
Re: looping in array vs looping in a dic Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-20 13:29 -0600
Re: looping in array vs looping in a dic giuseppe.amatulli@gmail.com - 2012-09-20 16:35 -0700
Re: looping in array vs looping in a dic MRAB <python@mrabarnett.plus.com> - 2012-09-21 00:58 +0100
Re: looping in array vs looping in a dic giuseppe.amatulli@gmail.com - 2012-09-20 16:35 -0700
csiph-web