Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75794
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <usethisid2014@gmail.com> |
| 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; '16,': 0.03; 'indices': 0.07; '22,': 0.09; '34,': 0.09; '40,': 0.09; 'method,': 0.09; 'cheers': 0.12; '2],': 0.16; '37,': 0.16; '46,': 0.16; '49,': 0.16; '52,': 0.16; '55,': 0.16; '58,': 0.16; '61,': 0.16; '64,': 0.16; '67,': 0.16; '70,': 0.16; 'matters,': 0.16; 'numpy': 0.16; 'subject:skip:m 10': 0.16; 'wrote:': 0.18; 'wed,': 0.18; '>>>': 0.22; 'aug': 0.22; 'email addr:gmail.com>': 0.22; '>>>': 0.24; '31,': 0.24; 'simpler': 0.24; "haven't": 0.24; "i've": 0.25; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; '13,': 0.31; '25,': 0.31; 'dimensions': 0.31; 'loads': 0.31; 'url:python': 0.33; "i'd": 0.34; 'problem': 0.35; 'problem.': 0.35; 'tool': 0.35; 'something': 0.35; 'operations': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'really': 0.36; 'url:listinfo': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'being': 0.38; 'skip:& 10': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'space': 0.40; 'url:mail': 0.40; 'further': 0.61; 'dear': 0.65; 'dont': 0.67; 'yes': 0.68; 'frank': 0.68; 'evaluate': 0.72; 'clearer': 0.84; 'dimensional': 0.84; 'subject:space': 0.84; 'technique': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=uijkDkQSeqHQOUMdzPLKgItkzWyv8ryJoznrNQAwoPA=; b=d2bfk4/uFOaJ8XQrF2V2syYyDCdFouQDqf4MqRT1Ee/cgy4Vm2NiRvVAid7pdGRnv2 4wWxVp9CiZxbFRr+sYSzLATyRW56OWuE8sklz1T+Tvn+SQm+X4jtVBdPxujFcYRNyM/U hCJTZnzr9POfLBiNxeQFZgeSnYmsZZ4NOy/ntFzj8PhnGNj2VCeyvdI9J4pLed/aMd39 PUGt4MJheD4+ir7xM37IS8w2vsXfGWli8yivee4g6M1rDm/lmZDTIUJcRtb2NWo76wla lgOS2mA1gZcVJBSgj3xEaTYoKosTw6BThQr/S8OeafEKKTnFgFDNqO31rxgtfkooK/P9 XX8w== |
| MIME-Version | 1.0 |
| X-Received | by 10.194.9.228 with SMTP id d4mr14764100wjb.99.1407327223325; Wed, 06 Aug 2014 05:13:43 -0700 (PDT) |
| In-Reply-To | <53E1E180.6070308@gmail.com> |
| References | <lrrdfc$7q7$1@dont-email.me> <53E1E180.6070308@gmail.com> |
| Date | Wed, 6 Aug 2014 17:43:43 +0530 |
| Subject | Re: Pythonic way to iterate through multidimensional space? |
| From | Gayathri J <usethisid2014@gmail.com> |
| To | python-list@python.org |
| Content-Type | multipart/alternative; boundary=047d7b4508a83aa8d604fff4e7e0 |
| X-Mailman-Approved-At | Wed, 06 Aug 2014 14:14:10 +0200 |
| 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 | <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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12698.1407327251.18130.python-list@python.org> (permalink) |
| Lines | 209 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1407327251 news.xs4all.nl 2874 [2001:888:2000:d::a6]:36402 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:75794 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Dear Peter Yes the f[t] or f[:,:,:] might give a marginal increase, but then i need to do further operations using the indices, in which case this wouldnt help Dear Wojciech np.flat() works if u dont care about the indices and only the matrix/array values matter. but if the <i,j,k> matters, flatten wouldnt work On Wed, Aug 6, 2014 at 1:34 PM, Wojciech Giel <wojtekgiel@gmail.com> wrote: > You might check numpy it is really powerful tool for working with multi > dimensional arrays: > > ex. > >>> a = arange(81).reshape(3,3,3,3) > >>> a > > array([[[[ 0, 1, 2], > [ 3, 4, 5], > [ 6, 7, 8]], > > [[ 9, 10, 11], > [12, 13, 14], > [15, 16, 17]], > > [[18, 19, 20], > [21, 22, 23], > [24, 25, 26]]], > > > [[[27, 28, 29], > [30, 31, 32], > [33, 34, 35]], > > [[36, 37, 38], > [39, 40, 41], > [42, 43, 44]], > > [[45, 46, 47], > [48, 49, 50], > [51, 52, 53]]], > > > [[[54, 55, 56], > [57, 58, 59], > [60, 61, 62]], > > [[63, 64, 65], > [66, 67, 68], > [69, 70, 71]], > > [[72, 73, 74], > [75, 76, 77], > [78, 79, 80]]]]) > > >>> f = a.flat > >>> for i in f: > ... print(i) > 0 > 1 > 2 > .. > 98 > 99 > > cheers > Wojciech > > > > > On 05/08/14 21:06, Frank Miles wrote: > >> I need to evaluate a complicated function over a multidimensional space >> as part of an optimization problem. This is a somewhat general problem >> in which the number of dimensions and the function being evaluated can >> vary from problem to problem. >> >> I've got a working version (with loads of conditionals, and it only works >> to #dimensions <= 10), but I'd like something simpler and clearer and >> less hard-coded. >> >> I've web-searched for some plausible method, but haven't found anything >> "nice". Any recommendations where I should look, or what technique should >> be used? >> >> TIA! >> > > -- > https://mail.python.org/mailman/listinfo/python-list >
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Pythonic way to iterate through multidimensional space? Frank Miles <fpm@u.washington.edu> - 2014-08-05 20:06 +0000
Re: Pythonic way to iterate through multidimensional space? Peter Otten <__peter__@web.de> - 2014-08-05 22:48 +0200
Re: Pythonic way to iterate through multidimensional space? Frank Miles <fpm@u.washington.edu> - 2014-08-05 20:57 +0000
Re: Pythonic way to iterate through multidimensional space? Gayathri J <usethisid2014@gmail.com> - 2014-08-06 11:04 +0530
Re: Pythonic way to iterate through multidimensional space? Chris Angelico <rosuav@gmail.com> - 2014-08-06 16:25 +1000
Re: Pythonic way to iterate through multidimensional space? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-06 08:33 +0100
Re: Pythonic way to iterate through multidimensional space? Peter Otten <__peter__@web.de> - 2014-08-06 09:39 +0200
Re: Pythonic way to iterate through multidimensional space? Tim Chase <python.list@tim.thechases.com> - 2014-08-06 06:39 -0500
Re: Pythonic way to iterate through multidimensional space? Wojciech Giel <wojtekgiel@gmail.com> - 2014-08-06 09:04 +0100
Re: Pythonic way to iterate through multidimensional space? Gayathri J <usethisid2014@gmail.com> - 2014-08-06 17:43 +0530
Re: Pythonic way to iterate through multidimensional space? Peter Otten <__peter__@web.de> - 2014-08-06 14:39 +0200
Re: Pythonic way to iterate through multidimensional space? Gayathri J <usethisid2014@gmail.com> - 2014-08-06 18:57 +0530
csiph-web