[Numpy-discussion] trivial question: how to compare dtype - but ignoring byteorder ?

Karol Langner karol.langner at kn.pl
Mon Jul 24 05:18:55 CDT 2006


On Monday 24 July 2006 06:47, 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 !)
>
> Thanks,
> Sebastian Haase

The condition will always be False, because you're comparing wrong things 
here, numpy.float32 is a scalar type, not a dtype.

>>> numpy.float32
<type 'float32scalar'>
>>> type(numpy.dtype('>f4'))
<type 'numpy.dtype'>

And I think byteorder matters when comparing dtypes:
>>> numpy.dtype('>f4') == numpy.dtype('<f4')
False

Cheers,
Karol

-- 
written by Karol Langner
pon lip 24 12:05:54 CEST 2006




More information about the Numpy-discussion mailing list