[Numpy-discussion] bool value of dtype is False?
Alexander Belopolsky
ndarray at mac.com
Fri Feb 14 19:59:43 EST 2014
On Fri, Feb 14, 2014 at 4:51 PM, Charles G. Waldman <charles at crunch.io>wrote:
> >>> d = numpy.dtype(int)
> >>> if d: print "OK"
> ... else: print "I'm surprised"
>
> I'm surprised
> _______________________________________________
>
I think this is an artifact of regular dtypes having "length" of zero:
>>> len(array(1.).dtype)
0
For record arrays dtypes you would get True:
>>> len(numpy.dtype([('x', int)]))
1
>>> bool(numpy.dtype([('x', int)]))
True
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140214/ee3dbb8b/attachment.html>
More information about the NumPy-Discussion
mailing list