Sebastian Haase wrote:
Hi, if I have a numpy array 'a' and say: a.dtype == numpy.float32
Is the result independent of a's byteorder ? (That's what I would expect ! Just checking !)
I think I misread the question and saw "==" as "="
But, the answer I gave should still help: the byteorder is a property of the data-type. There is no such thing as "a's" byteorder. Thus, numpy.float32 (which is actually an array-scalar and not a true data-type) is interepreted as a machine-byte-order IEEE floating-point data-type with 32 bits. Thus, the result will depend on whether or not a.dtype is machine-order or not.
-Travis 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
On Monday 24 July 2006 12:36, Travis Oliphant wrote: 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 ... This seems to work independent of byteorder - (but looks ugly(er)) ... Is this the best way of doing this ? - Sebastian Haase