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

Sebastian Haase haase@msg.ucsf....
Tue Nov 13 06:11:33 CST 2007


Hi,
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