What is the reason for this weirdness in numpy’s all?
>>> import numpy as np
>>> np.all(xrange(10))
False
>>> np.all(i for i in xrange(10))
True
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Numpy.all does not understands generator expressions.
From the documentation
Ok, not very explicit, so lets look at the code
As generator expression doesn’t have
allmethod, it ends up calling_wrapitIn
_wrapit, it first checks for__array_wrap__method whichgenerates AttributeErrorfinally ending up callingasarrayon the generator expressionFrom the documentation of
numpy.asarrayIt is well documented about the various types of Input data thats accepted which is definitely not generator expression
Finally, trying