[Numpy-discussion] trivial question: how to compare dtype - but ignoring byteorder ?
Travis Oliphant
oliphant.travis at ieee.org
Mon Aug 14 15:32:05 EDT 2006
> Hi,
> I just realized that this question did actually not get sorted out.
> Now I'm just about to convert my code to compare
> arr.dtype.type to the (default scalar!) dtype numpy.uint8
> like this:
> if self.img.dtype.type == N.uint8:
> self.hist_min, self.hist_max = 0, 1<<8
> elif self.img.dtype.type == N.uint16:
> self.hist_min, self.hist_max = 0, 1<<16
> ...
>
>
Yes, you can do this and it should work independent of byteorder. The
dtype comparison will take into account the byte-order but comparing the
type objects directly won't. So, if that is your intent, then great.
-Travis
More information about the NumPy-Discussion
mailing list