Yes you are rightI figured that out after posting to python list.. actually my index is reaching the last point.. and my prog is not doing what I want.. I am wondering why it is reaching the last point in my list .. its never stopping in between ??? <br>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Nov 20, 2012 at 2:01 PM, Dave Angel <span dir="ltr"><<a href="mailto:d@davea.name" target="_blank">d@davea.name</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On 11/20/2012 07:31 AM, inshu chauhan wrote:<br>
> I did the following changes in this part of my programme.. now the<br>
> refereence error is removed but its showing me another error :<br>
><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>
><br>
>             if data[cy,cx] == (0.0,0.0,0.0):<br>
>                 continue<br>
>             else :<br>
>                 centre = data[cy, cx]<br>
>                 print centre<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>
>                     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>
><br>
>                             dist = distance(centre, point)<br>
>                             if  dist < radius :<br>
>                                 print point<br>
>                                 points.append(point)<br>
>                                 change = True<br>
>                                 print change<br>
><br>
><br>
>                 break<br>
><br>
><br>
>             print points<br>
><br>
><br>
> ERROR :<br>
><br>
> Traceback (most recent call last):<br>
>   File "Z:/modules/classification1.py", line 71, in <module><br>
>     ComputeClasses(data)<br>
>   File "Z:/modules/classification1.py", line 47, in ComputeClasses<br>
>     point = data[idx[0], idx[1]]<br>
> error: index is out of range<br>
><br>
> What is meant by this statement ' Index out of range ' ? Does it mean that<br>
> my range 1, 1000 is exceeded ??<br>
><br>
><br>
<br>
</div></div>When you're using custom classes that mimic the standard ones, the error<br>
can mean most anything.  But assuming the design was to keep as close as<br>
possible, it simply means that you're subscripting a list with an index<br>
that's too large or too small.  So if idx is a list that has only one<br>
element, element number zero, then idx[1] would be out of range.  On the<br>
same line, if data is acting kind of like a two-dimensional list, then<br>
it has limits on each dimension, and either idx[0] is too big/small for<br>
the first dimension, or idx[1] is too big or small for the second.<br>
<br>
First thing is to figure out which part of this expression is causing<br>
the exception.  So do a separate pair of assignments,<br>
    dummy0 = idx[0]<br>
    dummy1 = idx[1]<br>
<br>
and then  point = data[dummy0, dummy1]<br>
<br>
Incidentally, if idx is a tuple or a list, of exactly two items, then<br>
you could just say<br>
       point = data[*idx]<br>
<br>
Anyway, if that still doesn't make things clear, then print dummy0 and<br>
dummy1 before the point= line.  That way you can see the last value, the<br>
one it dies on, just before the stack trace.  Naturally, you could also<br>
print the size attributes of the data item as well.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
<br>
DaveA<br>
<br>
</font></span></blockquote></div><br></div>