<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Nov 14, 2012 at 10:18 AM, inshu chauhan <span dir="ltr"><<a href="mailto:insideshoes@gmail.com" target="_blank">insideshoes@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>for this code m getting this error :<br><br>CODE : <br>def ComputeClasses(data):<br> radius = .5 <br> points = []<br>
for cy in xrange(0, data.height):<br> for cx in xrange(0, data.width):<br> if data[cy,cx] != (0.0,0.0,0.0):<br></blockquote><div>This code is only run if the test above is true <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
centre = data[cy, cx]<br> points.append(centre) <br> <br><br> change = True<br><br> while change:<br> <br> for ring_number in xrange(1, 1000):<br>
change = False<br> new_indices = GenerateRing(cx, cy, ring_number)<br> <br><br> for idx in new_indices:<br> point = data[idx[0], idx[1]]<br>
<br> if point == (0.0, 0.0, 0.0 ):<br> continue<br> else:<br> dist = distance(centre, point)<br></blockquote>
<div>centre is only set if the test above is true. In your run, it apparently wasn't <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> if dist < radius :<br>
print point <br> points.append(point)<br> change = True<br> print change<br> <br>
<br> break <br><br><br>ERROR : <br>Traceback (most recent call last):<br> File "Z:\modules\classification2.py", line 74, in <module><br> ComputeClasses(data)<br> File "Z:\modules\classification2.py", line 56, in ComputeClasses<br>
dist = distance(centre, point)<br>UnboundLocalError: local variable 'centre' referenced before assignment<br><br>And i am unable to understand .. WHY ?<br><br><br>
<br>--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Joel Goldstick<br><br>
</div>