|
if data.dtype is not np.ubyte: |
It looks like, ndarray.dtype cant be checked using "is" or "is not", it should be compared using == operator:
In [1]: import numpy as np
In [2]: np.array([1,2], dtype=np.ubyte)
Out[2]: array([1, 2], dtype=uint8)
In [3]: x = _
In [4]: x.dtype
Out[4]: dtype('uint8')
In [5]: x.dtype is not np.ubyte
Out[5]: True
In [6]: x.dtype == np.ubyte
Out[6]: True