Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75785
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <wojtekgiel@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; '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; 'numpy': 0.16; 'subject:skip:m 10': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header:User-Agent:1': 0.23; '31,': 0.24; "haven't": 0.24; "i've": 0.25; 'header:In-Reply-To:1': 0.27; 'function': 0.29; '13,': 0.31; '25,': 0.31; 'dimensions': 0.31; 'loads': 0.31; 'problem': 0.35; 'problem.': 0.35; 'tool': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'really': 0.36; 'subject:?': 0.36; 'should': 0.36; 'being': 0.38; 'message- id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'space': 0.40; 'charset:windows-1252': 0.65; 'frank': 0.68; 'evaluate': 0.72; '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=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=Ms0USoT+oazLvGWphsk+Z8mxM8jt3WQhuT8KabtzvNU=; b=N3cwmd+LIOKb7fnUCZnFgR162FjouV4LK2O7OVontdgTZAkzo2ukCdpscBUjFdyDJH VOoni7gghREM0aTs9ZR9zgITw3qKB01qqAqMJxAj8sfv180brc38VpGWlLOcCUgG9EVv B+63ltb9RcIXCxoVz0kl8Vd/+aP70H2SkQoXlwQNBDO+WW5+hZzlc/Iz9U0okzLTKNBS iAYgJYTAN/PDELmBQSpQ4hJxU85xj58Bn8uSHjMW70tAf1ZGOsG6GiNu6SkhOBapiYhf XHwJ3fuHlnmAoZS1c5JaG3rKPyO0tFGucVq+vstzmsNNAt9Kx7z76eMuaLNA8UR9Lv6t oRpg== |
| X-Received | by 10.194.10.167 with SMTP id j7mr13983004wjb.100.1407312258715; Wed, 06 Aug 2014 01:04:18 -0700 (PDT) |
| Date | Wed, 06 Aug 2014 09:04:16 +0100 |
| From | Wojciech Giel <wojtekgiel@gmail.com> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Pythonic way to iterate through multidimensional space? |
| References | <lrrdfc$7q7$1@dont-email.me> |
| In-Reply-To | <lrrdfc$7q7$1@dont-email.me> |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| 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.12692.1407312265.18130.python-list@python.org> (permalink) |
| Lines | 76 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1407312265 news.xs4all.nl 2851 [2001:888:2000:d::a6]:44708 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:75785 |
Show key headers only | View raw
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!
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