keflavich
keflavich

Reputation: 19205

Why is np.dtype(None) = float?

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.

Upvotes: 3

Views: 467

Answers (1)

JoshAdel
JoshAdel

Reputation: 68682

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

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

Upvotes: 4

Related Questions