On 11/13/2014 12:37 PM, Antony Lee wrote:
> On Python3, __nonzero__ is never defined (always raises an AttributeError), 
> even after calling __bool__.


The example I posted was Python 3.4.1 with numpy 1.9.0.

fwiw,
Alan Isaac

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> import numpy as np
 >>> np.__version__
'1.9.0'
 >>> t = np.array(None); t[()] = np.array([None, None])
 >>> t.__nonzero__()
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
AttributeError: 'numpy.ndarray' object has no attribute '__nonzero__'
 >>> t.__bool__()
True
 >>> t.__nonzero__()
ValueError: The truth value of an array with more than one element is 
ambiguous. Use a.any() or a.all()
 >>>


_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to