Re: Index Error

2012-11-21 Thread inshu chauhan
I guess I have to use try and except as Chris suggested, this isn't working. -- http://mail.python.org/mailman/listinfo/python-list

Re: Index Error

2012-11-21 Thread Dave Angel
> > > >> >> 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.. > I'll paste an e

Re: Index Error

2012-11-21 Thread Dave Angel
On 11/21/2012 05:11 AM, inshu chauhan wrote: >> >>> >> 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

Re: Index Error

2012-11-21 Thread inshu chauhan
> > > > 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)) >

Re: Index Error

2012-11-21 Thread inshu chauhan
> > > > >> 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 ar

RE: Index Error

2012-11-20 Thread Prasad, Ramit
Can you please post in plain text and stop top-posting? Thanks. inshu chauhan wrote: > > 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): Gen

Re: Index Error

2012-11-20 Thread Dave Angel
On 11/20/2012 10:01 AM, inshu chauhan wrote: >> >> >> So did you read the following paragraphs? You should not be using "and" >> in that expression. > > > >> 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

Re: Index Error

2012-11-20 Thread inshu chauhan
I dont want error actually to come. With try nd except , the error will come but without affecting my prog... -- http://mail.python.org/mailman/listinfo/python-list

Re: Index Error

2012-11-20 Thread inshu chauhan
The catch to the approach suggested by Chris is that you DON'T want to > break out of the whole loop when one value is out of range. You only > want to skip that one point. > > > Yes I want to skip only that one point (centre) but try and expect seems to be the last option.. I would like to try o

Re: Index Error

2012-11-20 Thread inshu chauhan
> > > So did you read the following paragraphs? You should not be using "and" > in that expression. > Yes i tried "or" also but no use . > > >> > >> You do not want "and" in that expression. The way you've coded it, > >> it'll only skip items in which both indices are out of range. Change

Re: Index Error

2012-11-20 Thread Dave Angel
On 11/20/2012 09:26 AM, inshu chauhan wrote: >> 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)) >>

Re: Index Error

2012-11-20 Thread Dave Angel
On 11/20/2012 09:11 AM, inshu chauhan wrote: > On Tue, Nov 20, 2012 at 3:00 PM, Chris Angelico wrote: > >> On Wed, Nov 21, 2012 at 12:57 AM, inshu chauhan >> wrote: >>> I am using python 2.7.3 , so can it be done in that ? >> (Please don't top-post; just delete the couple of blank lines that >> g

Re: Index Error

2012-11-20 Thread inshu chauhan
> 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)) > >

Re: Index Error

2012-11-20 Thread inshu chauhan
On Tue, Nov 20, 2012 at 3:00 PM, Chris Angelico wrote: > On Wed, Nov 21, 2012 at 12:57 AM, inshu chauhan > wrote: > > I am using python 2.7.3 , so can it be done in that ? > > (Please don't top-post; just delete the couple of blank lines that > gmail oh so kindly provides, and type your response

Re: Index Error

2012-11-20 Thread Dave Angel
On 11/20/2012 08:43 AM, inshu chauhan wrote: > 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 >

Re: Index Error

2012-11-20 Thread Chris Angelico
On Wed, Nov 21, 2012 at 12:57 AM, inshu chauhan wrote: > I am using python 2.7.3 , so can it be done in that ? (Please don't top-post; just delete the couple of blank lines that gmail oh so kindly provides, and type your response at the bottom. You may also want to consider trimming the quoted te

Re: Index Error

2012-11-20 Thread inshu chauhan
I am using python 2.7.3 , so can it be done in that ? On Tue, Nov 20, 2012 at 2:48 PM, Chris Angelico wrote: > On Wed, Nov 21, 2012 at 12:43 AM, inshu chauhan > wrote: > > 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...

Re: Index Error

2012-11-20 Thread Chris Angelico
On Wed, Nov 21, 2012 at 12:43 AM, inshu chauhan wrote: > 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. > > Traceback (most recent call last): > File "Z:/modules/Classify.py", line 73, in > ComputeClasses(data) > Fi