<div dir="ltr"><div><div>Dunno, seems unlikely that something changed with Python 3.4.2...</div><div>$ python --version<br></div></div><div><div>Python 3.4.2</div></div><div>$ python -c 'import numpy as np; print(np.__version__); t = np.array(None); t[()] = np.array([None, None]); t.__bool__(); t.__nonzero__()'</div><div>1.9.0</div><div><div>Traceback (most recent call last):</div><div>  File "<string>", line 1, in <module></div><div>AttributeError: 'numpy.ndarray' object has no attribute '__nonzero__'</div></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-11-13 10:05 GMT-08:00 Alan G Isaac <span dir="ltr"><<a href="mailto:alan.isaac@gmail.com" target="_blank">alan.isaac@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 11/13/2014 12:37 PM, Antony Lee wrote:<br>
> On Python3, __nonzero__ is never defined (always raises an AttributeError), even after calling __bool__.<br>
<br>
<br>
</span>The example I posted was Python 3.4.1 with numpy 1.9.0.<br>
<br>
fwiw,<br>
Alan Isaac<br>
<br>
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] on win32<br>
Type "help", "copyright", "credits" or "license" for more information.<br>
 >>> import numpy as np<br>
<span class="im HOEnZb"> >>> np.__version__<br>
'1.9.0'<br>
 >>> t = np.array(None); t[()] = np.array([None, None])<br>
 >>> t.__nonzero__()<br>
Traceback (most recent call last):<br>
   File "<stdin>", line 1, in <module><br>
AttributeError: 'numpy.ndarray' object has no attribute '__nonzero__'<br>
 >>> t.__bool__()<br>
True<br>
 >>> t.__nonzero__()<br>
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()<br>
 >>><br>
<br>
<br>
</span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</div></div></blockquote></div><br></div>