Created
October 10, 2014 17:56
-
-
Save dhermes/a24efeed7b2752454340 to your computer and use it in GitHub Desktop.
NumPy array truthiness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import numpy as np | |
>>> bool(np.array([])) | |
False | |
>>> bool(np.array([1])) | |
True | |
>>> bool(np.array([0])) | |
False | |
>>> bool(np.array([0,0])) | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment