[Numpy-discussion] bool value of dtype is False?

2014-02-14 Thread Charles G. Waldman
 d = numpy.dtype(int)
 if d: print OK
... else: print I'm surprised

I'm surprised
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] bool value of dtype is False?

2014-02-14 Thread Alexander Belopolsky
On Fri, Feb 14, 2014 at 4:51 PM, Charles G. Waldman char...@crunch.iowrote:

  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
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion