Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33622
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <d@davea.name> |
| 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; 'else:': 0.03; 'function,': 0.07; 'indices': 0.07; 'subject:Error': 0.07; 'logic': 0.09; 'negative.': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'index': 0.13; 'passing': 0.15; '"and"': 0.16; '0.0,': 0.16; 'dist': 0.16; 'expression.': 0.16; 'idx': 0.16; 'intended.': 0.16; 'query,': 0.16; 'range.': 0.16; 'rings': 0.16; 'subject:Index': 0.16; 'there..': 0.16; 'wrote:': 0.17; 'skip': 0.17; '>>>': 0.18; 'trying': 0.21; 'earlier': 0.21; 'terminate': 0.22; 'for?': 0.23; 'device': 0.24; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'values': 0.26; 'am,': 0.27; 'cc:addr:gmail.com': 0.27; 'question': 0.27; 'there.': 0.28; 'coded': 0.29; 'points': 0.29; 'point': 0.31; 'print': 0.32; 'doubt': 0.33; 'doing': 0.35; 'continue': 0.35; 'next': 0.35; 'but': 0.36; 'method': 0.36; 'should': 0.36; 'skip:p 20': 0.36; 'unable': 0.36; 'possible': 0.37; 'why': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'sure': 0.38; 'received:192': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'help': 0.40; 'your': 0.60; 'range': 0.60; "you've": 0.61; 'repeat': 0.62; 'here': 0.65; 'total': 0.65; 'header:Reply-To:1': 0.68; '3000': 0.71; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'square': 0.75; 'satisfied': 0.83; 'matrix.': 0.84; 'received:74.208.4.194': 0.84; 'subscripts': 0.84; 'clip': 0.93 |
| Date | Tue, 20 Nov 2012 09:46:28 -0500 |
| From | Dave Angel <d@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 |
| MIME-Version | 1.0 |
| To | inshu chauhan <insideshoes@gmail.com> |
| Subject | Re: Index Error |
| References | <CAFqGZRHSZ2QTqw=_iZWCWVJXVoxEZvHkTEmb-QeohRer2hjj7w@mail.gmail.com> <50AB8FB1.2030208@davea.name> <CAFqGZRG3eu21YxBwcJ=vb-ZSgG8DszEhjkcU1ppAKpUPBO_5Yg@mail.gmail.com> |
| In-Reply-To | <CAFqGZRG3eu21YxBwcJ=vb-ZSgG8DszEhjkcU1ppAKpUPBO_5Yg@mail.gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V02:K0:3N1DDSCLN/NDsflrpNBUu6Mmi3I2o7hIShHVyx3WGBG NK0jW2nO1B0Tw2ws4s1+ht5OZAZ1yPHQsQz4vGi1VSY/Nxj4Wf s7f0KV2aTL31exN5i+g+NUyKLiuZlEhYtEGVsLd2IvjvcmxP94 /NxZcwSC385WWgbZtp3SKdd8Vt+wRQLZgzUCjOV2NsPZxMg1ah fYP7ITYDDN4ZaOdrm/GEWM0PWWMClFkBONlBMl9sGPb15pu9uk rdF8p1/fvyLiUPpeI8lXKkKMMio53GS6V/+OdI8zalpvuRapVF +8+pSdwsVLKqcdKEriIJrntS40G7OcgH7jKM84EhvPK4woeDA= = |
| Cc | "python-list@python.org" <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | d@davea.name |
| 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.59.1353422809.29569.python-list@python.org> (permalink) |
| Lines | 81 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1353422809 news.xs4all.nl 6972 [2001:888:2000:d::a6]:38832 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:33622 |
Show key headers only | View raw
On 11/20/2012 09:26 AM, inshu chauhan wrote: >> def GenerateRing(x,y, N): Generates square rings around a point in data >>> which has 300 columns(x) and 3000 rows(y) >>> indices = [] >>> for i in xrange(-N, N): >>> indices.append((x+i, y-N)) >>> indices.append((x+N, y+i)) >>> indices.append((x-i, y+N)) >>> indices.append((x-N, y-i)) >>> return indices >>> >> Is it possible that N is greater than either x or y ? Are negative >> subscripts permissible? >> >> You should consider doing the clipping logic in this function, perhaps >> by passing xlimit and ylimit in as arguments.> >> > > > Yes N cannot be greater than x and y and it cant be negative too... > >> I need help in this part as I am unable to device a method in >> which if the >> points are out of index,it should stop and >> if idx[0] >= 300 and idx[1] >= 3000: go >> to next centre and start generating rings from there.. and again if the >> index is out of range .. this should repeat > > This is where you're trying to clip the values that may be outside of >> the total matrix. >> > > Yes I am trying to clip the values here but its not working actually , I > mean not at all working > So did you read the following paragraphs? You should not be using "and" in that expression. >> >> You do not want "and" in that expression. The way you've coded it, >> it'll only skip items in which both indices are out of range. Change it to >> if idx[0] >= data.width or idx[1] >= data.height: >> >> and depending on your answer to my earlier query, you may want to also >> check if either subscript is negative. >> >>> continue >>> else : >>> point = data[idx[0], idx[1]] >>> if point == (0.0, 0.0, 0.0 ): >>> print point >>> continue >>> else: >>> dist = distance(centre, point) >>> print dist >>> if dist < radius : and >> rings >>> should be added only when this condition is satisfied >>> print point >>> points.append(point) >>> change = True >>> print change >>> >>> >>> break >> >> Why do you want to terminate the loop after only iteration? >> > > I dint get your question ?? > You have a break there. What's it for? It'll make sure you only process one of the idx values from new_indices. i doubt that's what you intended. -- DaveA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Index Error Dave Angel <d@davea.name> - 2012-11-20 09:46 -0500
csiph-web