Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #71975
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'operator': 0.03; 'say,': 0.05; 'element': 0.07; 'great.': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'question.': 0.14; 'kern': 0.16; 'luis': 0.16; 'numpy': 0.16; 'operation,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'underlying': 0.16; 'url:faq': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'header:User- Agent:1': 0.23; 'interpret': 0.24; 'lets': 0.24; "shouldn't": 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'array': 0.29; 'robert': 0.30; 'sets': 0.30; 'anyone': 0.31; 'lists': 0.32; 'url:python': 0.33; 'add': 0.35; 'in:': 0.36; 'doing': 0.36; 'url:org': 0.36; 'list': 0.37; 'to:addr:python- list': 0.38; 'explain': 0.39; 'obtain': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'hope': 0.61; "you're": 0.61; 'our': 0.64; 'world': 0.66; 'believe': 0.68; 'results': 0.69; 'union': 0.69; 'as:': 0.81; 'eco': 0.84; 'subject:Sets': 0.84; 'terrible': 0.84; 'want:': 0.84; 'received:86': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Robert Kern <robert.kern@gmail.com> |
| Subject | Re: Numpy Array of Sets |
| Date | Sat, 24 May 2014 23:14:32 +0100 |
| References | <38836877-cd87-44ce-b9df-1eda702e7164@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Gmane-NNTP-Posting-Host | cpc12-cmbg17-2-0-cust443.5-4.cable.virginm.net |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 |
| In-Reply-To | <38836877-cd87-44ce-b9df-1eda702e7164@googlegroups.com> |
| 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.10272.1400969687.18130.python-list@python.org> (permalink) |
| Lines | 33 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1400969687 news.xs4all.nl 2863 [2001:888:2000:d::a6]:43376 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:71975 |
Show key headers only | View raw
On 2014-05-24 23:05, Luis José Novoa wrote: > Hi All, > > Hope you're doing great. One quick question. I am defining an array of sets using numpy as: > > a=array([set([])]*3) > > Now, if I want to add an element to the set in, lets say, a[0], and I use the .add(4) operation, which results in: > > array([set([4]), set([4]), set([4])], dtype=object) > > which I do not want. If I use the union operator > > a[0] = a[0] | set([4]) > > then I obtain what I want: > > array([set([4]), set([]), set([])], dtype=object) > > Can anyone explain whay this happens? Same reason why you shouldn't make a list of lists like so: [[]]*3 https://docs.python.org/2/faq/programming.html#how-do-i-create-a-multidimensional-list -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Numpy Array of Sets Luis José Novoa <luisjosenovoa@gmail.com> - 2014-05-24 15:05 -0700
Re: Numpy Array of Sets Robert Kern <robert.kern@gmail.com> - 2014-05-24 23:14 +0100
Re: Numpy Array of Sets Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2014-05-25 00:25 +0200
Re: Numpy Array of Sets LJ <luisjosenovoa@gmail.com> - 2014-05-25 05:29 -0700
Re: Numpy Array of Sets Peter Otten <__peter__@web.de> - 2014-05-25 15:26 +0200
Re: Numpy Array of Sets LJ <luisjosenovoa@gmail.com> - 2014-05-25 07:14 -0700
Re: Numpy Array of Sets Peter Otten <__peter__@web.de> - 2014-05-25 17:12 +0200
Re: Numpy Array of Sets LJ <luisjosenovoa@gmail.com> - 2014-05-25 08:17 -0700
csiph-web