On Tuesday, January 31, 2012, Alan G Isaac <alan.is...@gmail.com> wrote:
> On 1/31/2012 8:26 AM, Neal Becker wrote:
>> I was just bitten by this unexpected behavior:
>>
>> In [24]: all ([i>   0 for i in xrange (10)])
>> Out[24]: False
>>
>> In [25]: all (i>   0 for i in xrange (10))
>> Out[25]: True
>>
>> Turns out:
>> In [31]: all is numpy.all
>> Out[31]: True
>
>
>>>> np.array([i>  0 for i in xrange (10)])
> array([False,  True,  True,  True,  True,  True,  True,  True,  True,
 True], dtype=bool)
>>>> np.array(i>  0 for i in xrange (10))
> array(<generator object <genexpr> at 0x0267A210>, dtype=object)
>>>> import this
>
>
> Cheers,
> Alan
>

Is np.all() using np.array() or np.asanyarray()?  If the latter, I would
expect it to return a numpy array from a generator.  If the former, why
isn't it using asanyarray()?

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

Reply via email to