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 <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()
>From the attached script: > if temp_za == j: > counter += 1 Do you want to count the entries? >>> temp_za = numpy.array([1, 2, 3, 2, 1, 1]) >>> (temp_za == 1).sum() 3 > This error occurs when the temp_za ( a numpy array, print temp_za works > fine) is compared with j. I am attaching the code. I'm sorry, I am lacking the domain knowledge to make sense of it. Just one more remark: [] < 0.0 is always False, regardless of the contents of the list > 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. I'd use numpy.array(p_za//2, dtype=int) but I'm not a numpy expert. As you dig deeper the tutor mailing list may not be the best place to ask -- numpy has a dedicated mailing list of its own. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor