Re: [Tutor] IndexError: index out of bounds

2013-03-27 Thread Peter Otten
Sayan Chatterjee wrote: > Yes, when handled as a numpy array, it's working fine! > > Traceback (most recent call last): > File "ZA.py", line 59, in > if temp_za == j: > ValueError: The truth value of an array with more than one element is > ambiguous. Use a.any() or a.all() >From the atta

Re: [Tutor] IndexError: index out of bounds

2013-03-27 Thread Sayan Chatterjee
Hi Peter, Thanks!! Yes, when handled as a numpy array, it's working fine! Traceback (most recent call last): File "ZA.py", line 59, in if temp_za == j: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() This error occurs when the temp_

Re: [Tutor] IndexError: index out of bounds

2013-03-27 Thread Alan Gauld
On 27/03/13 17:36, Sayan Chatterjee wrote: 2) Traceback (most recent call last): File "ZA.py", line 43, in if p_za[i] > 4.0: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() This implies that p_za[i] is actually an array. So maybe

Re: [Tutor] IndexError: index out of bounds

2013-03-27 Thread Peter Otten
Sayan Chatterjee wrote: > Hi Walter, > Thanks a lot! > > Yes, now I get your point. append is working perfectly fine. > > Hi Peter: > > Exactly. It's very nice. Indices needn't have to be mentioned explicitly. > No explicit looping and the thing is done! > > But I have a question, whenever we

Re: [Tutor] IndexError: index out of bounds

2013-03-27 Thread Sayan Chatterjee
Hi Walter, Thanks a lot! Yes, now I get your point. append is working perfectly fine. Hi Peter: Exactly. It's very nice. Indices needn't have to be mentioned explicitly. No explicit looping and the thing is done! But I have a question, whenever we want to do operations on the individual array e

Re: [Tutor] IndexError: index out of bounds

2013-03-27 Thread Peter Otten
Sayan Chatterjee wrote: > When trying to print or assign array elements, getting the following > error: > > Traceback (most recent call last): > File "ZA.py", line 32, in > p_za[i] = p_initial[i] + t*K*cos(K*p_initial[i]); > IndexError: index out of bounds > > I am using Numpy, is it due

Re: [Tutor] IndexError: index out of bounds

2013-03-27 Thread Walter Prins
Hi Sayan, On 27 March 2013 16:31, Sayan Chatterjee wrote: > p_za = [None]*N is not giving away the error message. > > for i in range(0,N): > p_za.append = p_initial[i] + t*K*cos(K*p_initial[i]); is also not > working. > append() is a method, so using append you want something like: for i i

Re: [Tutor] IndexError: index out of bounds

2013-03-27 Thread Sayan Chatterjee
p_za = [None]*N is not giving away the error message. for i in range(0,N): p_za.append = p_initial[i] + t*K*cos(K*p_initial[i]); is also not working. Could you please redirect me to a link where the example is demonstrated? What is the simplest way to assign an array element a value? i.e the

Re: [Tutor] IndexError: index out of bounds

2013-03-27 Thread Walter Prins
Hi, On 27 March 2013 15:50, Sayan Chatterjee wrote: > Dear all, > > When trying to print or assign array elements, getting the following error: > > Traceback (most recent call last): > File "ZA.py", line 32, in > p_za[i] = p_initial[i] + t*K*cos(K*p_initial[i]); > IndexError: index out o

Re: [Tutor] IndexError: index out of bounds

2013-03-27 Thread Joel Goldstick
On Wed, Mar 27, 2013 at 11:50 AM, Sayan Chatterjee < sayanchatter...@gmail.com> wrote: > Dear all, > > When trying to print or assign array elements, getting the following error: > > Traceback (most recent call last): > File "ZA.py", line 32, in > p_za[i] = p_initial[i] + t*K*cos(K*p_initia

[Tutor] IndexError: index out of bounds

2013-03-27 Thread Sayan Chatterjee
Dear all, When trying to print or assign array elements, getting the following error: Traceback (most recent call last): File "ZA.py", line 32, in p_za[i] = p_initial[i] + t*K*cos(K*p_initial[i]); IndexError: index out of bounds I am using Numpy, is it due to that? I am attaching the code