Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33611
| Path | csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <insideshoes@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.010 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'else:': 0.03; 'error:': 0.05; 'indices': 0.07; 'subject:Error': 0.07; 'cc:addr:python- list': 0.10; 'def': 0.10; 'index': 0.13; '0.0,': 0.16; '49,': 0.16; 'dist': 0.16; 'idx': 0.16; 'rings': 0.16; 'subject:Index': 0.16; 'there..': 0.16; '<': 0.17; 'skip:\xa0 30': 0.17; 'received:209.85.216.46': 0.21; 'cc:2**0': 0.23; 'to:2**1': 0.23; 'device': 0.24; 'cc:addr:python.org': 0.25; 'skip:" 20': 0.26; '(most': 0.27; 'message-id:@mail.gmail.com': 0.27; 'points': 0.29; 'skip:& 10': 0.29; 'skip:& 30': 0.30; 'error': 0.30; 'point': 0.31; 'file': 0.32; 'print': 0.32; 'dies': 0.33; 'traceback': 0.33; 'received:google.com': 0.34; 'false': 0.35; 'skip:: 10': 0.35; 'continue': 0.35; 'received:209.85': 0.35; 'next': 0.35; 'loaded': 0.36; 'method': 0.36; 'should': 0.36; 'skip:p 20': 0.36; 'unable': 0.36; 'skip:3 10': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'data': 0.37; 'header:Received:5': 0.40; 'help': 0.40; 'range': 0.60; 'repeat': 0.62; '8bit%:100': 0.70; '3000': 0.71; 'skip:n 40': 0.72; 'square': 0.75; 'satisfied': 0.83; 'out..': 0.84; '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0': 0.84; '8bit%:67': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=Ob/JD0KqzdXB24zn2LG4e3ePlS35qCHX6jQiRkdGnG4=; b=fhEpFOglAjB+B8L3ZNxryYIdnd/OkB+nB8PMV4sDJ6wg+kROkQjgfNK7braJA6kwth kf8BzmCX0cUmgxXzqlfiw8iPgK3AOBR48c0GkRzVsMQRCxhmTo9O1EJvBeAGz6G8kVo4 0hnUfSsXd39v8FXz8gqMp9kb0T+5HZUjcrbp5PjhlfA45MfGZrdTnbxim9kXsPhQz7Ao qzwsLkHW6I5ucqrc33TnnH2Aj1BNsmv0mYnjv3HiIPUbxTRpHdmBxSvKnyTYoC31Ujo4 VGEnOpJMOTtIsFoBbvjLrq02wmTiXBDQ6PEP99Nxo8RtYe1ZpQHhtFwmyAM9GKNryGTF sXPA== |
| MIME-Version | 1.0 |
| Date | Tue, 20 Nov 2012 14:43:48 +0100 |
| Subject | Index Error |
| From | inshu chauhan <insideshoes@gmail.com> |
| To | d@davea.name, Zero Piraeus <schesis@gmail.com> |
| Content-Type | multipart/alternative; boundary=20cf3074b3a6705ffe04ceed6c03 |
| Cc | "python-list@python.org" <python-list@python.org> |
| 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.49.1353419032.29569.python-list@python.org> (permalink) |
| Lines | 156 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1353419032 news.xs4all.nl 6849 [2001:888:2000:d::a6]:51506 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:33611 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
def distance(c, p):
dist = sqrt(
((c[0]-p[0])**2) +
((c[1]-p[1])**2) +
((c[2]-p[2])**2)
)
return dist
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
def ComputeClasses(data):
radius = .5
points = []
for cy in xrange(0, data.height):
for cx in xrange(0, data.width):
if data[cy,cx] == (0.0,0.0,0.0):
continue
else :
centre = data[cy, cx]
points.append(centre)
change = True
while change:
for ring_number in xrange(1, 100):
change = False
new_indices = GenerateRing(cx, cy, ring_number)
print new_indices
for idx in new_indices:
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
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
print points
ERROR now :
data loaded
[(296, 403), (298, 403), (298, 405), (296, 405), (297, 403), (298, 404),
(297, 405), (296, 404)] ... I am printing Indices to know what index it
dies out..
Traceback (most recent call last):
File "Z:/modules/Classify.py", line 73, in <module>
ComputeClasses(data)
File "Z:/modules/Classify.py", line 49, in ComputeClasses
point = data[idx[0], idx[1]]
error: index is out of range
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Index Error inshu chauhan <insideshoes@gmail.com> - 2012-11-20 14:43 +0100
csiph-web