[Numpy-discussion] Using arr.dtype.type to check byteorder-independed dtype fails for bool

Sebastian Haase haase at msg.ucsf.edu
Tue Nov 13 07:11:33 EST 2007

I need to check the array dtype in a way that it is ignoring
differences coming only from big-endian vs. little-endian.
So far I was using a test like this successfully:
if arr.dtype.type == N.uint8:

This would test positively for both byte-orders independent of the
system's byteorder.

I just noticed however, that
if arr.dtype.type == N.bool:

always fails (evaluates to False)
Testing arr.dtype == N.bool, on the other hand works (Sitting at my
Windows-PC cannot test the byte-order problem though !)

While writing this email, I just found that
if arr.dtype.type == N.bool_:
works. (Note the trailing underscore !).    What is this ?

Thanks for help,hints and comments,
Sebastian Haase

More information about the NumPy-Discussion mailing list