Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is np.dtype(None) = float?

Tags:

numpy

Why is this the default behavior of numpy?

In [5]: np.dtype(None)
Out[5]: dtype('float64')

I was hoping to use np.issubdtype(None,float) for some type-checking involving return types for images (PIL likes 0-255 images, skimage likes [0,1) images), but that does not work. I'd be interested in a clean-looking workaround, but I'll be satisfied with an answer to the main question.

like image 845
keflavich Avatar asked May 05 '26 13:05

keflavich


1 Answers

This is a special case where None is converted to the default dtype. See:

https://github.com/numpy/numpy/issues/2190

like image 173
JoshAdel Avatar answered May 08 '26 20:05

JoshAdel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!