[Numpy-discussion] trivial question: how to compare dtype - but ignoring byteorder ?
oliphant.travis at ieee.org
Mon Aug 14 14:32:05 CDT 2006
> 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.
More information about the Numpy-discussion