Re: Error

Discussion in 'Python' started by Mark Lawrence, Nov 20, 2012.

  1. On 20/11/2012 12:31, inshu chauhan wrote:
    > I did the following changes in this part of my programme.. now the
    > refereence error is removed but its showing me another error :
    >
    > 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]
    > print centre
    > points.append(centre)
    >
    >
    > change = True
    >
    > while change:
    >
    > for ring_number in xrange(1, 1000):
    > change = False
    > new_indices = GenerateRing(cx, cy, ring_number)
    >
    > for idx in new_indices:
    > point = data[idx[0], idx[1]]
    >
    > if point == (0.0, 0.0, 0.0 ):
    > continue
    > else:
    >
    > dist = distance(centre, point)
    > if dist < radius :
    > print point
    > points.append(point)
    > change = True
    > print change
    >
    >
    > break
    >
    >
    > print points
    >
    >
    > ERROR :
    >
    > Traceback (most recent call last):
    > File "Z:/modules/classification1.py", line 71, in <module>
    > ComputeClasses(data)
    > File "Z:/modules/classification1.py", line 47, in ComputeClasses
    > point = data[idx[0], idx[1]]
    > error: index is out of range
    >
    > What is meant by this statement ' Index out of range ' ? Does it mean that
    > my range 1, 1000 is exceeded ??
    >
    >


    What makes you think the error applies to the value from the xrange
    call? The traceback tells you that the error has occurred at line 47.
    Looking at that and the lines above, I'd guess your problem lies in the
    return values from the GenerateRing function.

    --
    Cheers.

    Mark Lawrence.
     
    Mark Lawrence, Nov 20, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hfk0
    Replies:
    2
    Views:
    21,678
  2. JavaQueries
    Replies:
    1
    Views:
    3,676
    John C. Bollinger
    Mar 1, 2005
  3. Balaji
    Replies:
    3
    Views:
    10,115
  4. Bishop
    Replies:
    1
    Views:
    792
    Bishop
    Feb 24, 2007
  5. juvi
    Replies:
    3
    Views:
    1,054
    Alexey Smirnov
    Jan 22, 2009
Loading...

Share This Page