Index Error

inshu chauhan insideshoes at
Wed Nov 21 11:11:14 CET 2012

> >
> >> Yes i tried "or" also but no use .....
> Explain "no use".  If you mean you still fail, then what else did you
> try?  For example, did you try interchanging the two subscripts?  I've
> suspected all along that the meanings of row and column, x and y, [0]
> and [1], height and width are possibly confused.  Perhaps it'd be better
> if you used a similar terminology everywhere.

I tried using "or" instead of "and" interchanging also, still the index
error is coming.
x is no of column(300)  and y is no of rows(3000), [0] corresponds to x
i.e. column and [1]  corresponds to y i.e. row and
lastly height is y i.e row and width is column i.e. x

> Or perhaps you should simply make a class called Point, with attributes
> x and y.  And use instances of that class rather than tuples.  And start
> the function by defining  xmax and ymax, from  data.height and
> data.width (in whatever order matches the docs of that library you're
> using)


>>>>> 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?

> >>>   <snip>
> > The idea here is if no more point is added to the list of points i.e. all
> > points surrounding the centre is zero.. I want to break the loop and go
> to
> > the next point..
> >
> That's not at all what the break does.  But it's probably not what you
> meant to say anyway.
> >
> I think what you're saying is that you want to append at most one of the
> points from the ring.  In that case, the break is appropriate, but it'd
> be much clearer if it were inside the clause that triggers it, the place
> where you say points.append(point).  (naturally, it'd be at the end of
> that clause, following print change.)  In other words indent it to line
> up with print change.

Yes done that.. I totally agree..

> Back to an earlier comment.  I asked if N was ever bigger than x or
> bigger than y, and you said never.  But your ComputeClasses will have
> such a case the very first time around, when cx==0, cy==0, and
> ring_number == 1.

I doubt this , M confused..

> Have you actually tested a trivial nested loop:
>    for cy in xrange(0, data.height):
>         for cx in xrange(0, data.width):
>             point = data[cy, cx]
> to see whether it blows up.  And if it does, whether reversing cy and cx
> will change it?

Yes , I tested this. Its working fine, reversing cy and cx is not correct

> Your comment in the line:
>      if  dist < radius :    and rings should be added
>                    only when this condition is satisfied
> is confusing to me.  How can you make the call to GenerateRing() after
> this test, when this test is measuring something about one of the values
> returned by GenerateRing ?

Actually , this is one of my condition.. but i think It means that when
dist  is greater than radius
more points will not be added to the list , So the loop should stop here,
and next centre should be taken, creating second list and so on..

> I must confess I have no idea what data represents.  When you're doing
> rings, you use deltas on the cx and cy values.  But when you're
> computing radius, you use the 3d coordinates returned by  data[cx, cy].
>  So is data some kind of transformation, like a projection from a 3d
> object into a plane ?

If I say data is a yml image file.. does it makes sense ? Nyways I am
treating it as matrix with values.
Yes you can say that it is a projection of 3D objects onto a 2D plane..
which I am finding hard to work with !!!!!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list