[Tutor] IndexError: index out of bounds

Sayan Chatterjee sayanchatterjee at gmail.com
Wed Mar 27 19:54:13 CET 2013


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 <module>
    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_za ( a numpy array, print temp_za works
fine) is compared with j. I am attaching the code.

Another question  how do I get an integer value for  p_za / 2 . Type
casting with int says:
TypeError: only length-1 arrays can be converted to Python scalars.




On 27 March 2013 23:37, Alan Gauld <alan.gauld at btinternet.com> wrote:

> On 27/03/13 17:36, Sayan Chatterjee wrote:
>
>  2) Traceback (most recent call last):
>>    File "ZA.py", line 43, in <module>
>>      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 p_za is a list (of arrays)?
> Try printing it to see.
>
>
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
> ______________________________**_________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>



-- 


--------------------------------------------------------------------------
*Sayan  Chatterjee*
Dept. of Physics and Meteorology
IIT Kharagpur
Lal Bahadur Shastry Hall of Residence
Room AB 205
Mob: +91 9874513565
blog: www.blissprofound.blogspot.com

Volunteer , Padakshep
www.padakshep.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130328/3dbea988/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ZA.py
Type: application/octet-stream
Size: 1083 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20130328/3dbea988/attachment.obj>


More information about the Tutor mailing list