Fix dtype mismatch
@@ -34,7 +34,6 @@ cdef _init_dtype_dict():
dtype = numpy.dtype(i)
item = (dtype, dtype.itemsize)
_dtype_dict[i] = item
- _dtype_dict[dtype] = item
_dtype_dict[dtype.type] = item
for i in {str(numpy.dtype(i)) for i in all_type_chars}:
dtype = numpy.dtype(i)
@@ -46,6 +45,8 @@ _init_dtype_dict()
@cython.profile(False)
cpdef get_dtype(t):
+ if type(t) is numpy.dtype: # Exact type check
+ return t
ret = _dtype_dict.get(t, None)
if ret is None:
return numpy.dtype(t)
@@ -54,6 +55,8 @@ cpdef get_dtype(t):
@cython.profile(False)
cpdef tuple get_dtype_with_itemsize(t):
+ if type(t) is numpy.dtype: # Exact type check
+ return t, t.itemsize
ret = _dtype_dict.get(t, None)
if ret is None:
t = numpy.dtype(t)
