[Numpy-discussion] ones with non-native dtype byteorder

Eric Firing efiring@hawaii....
Mon Apr 14 13:59:30 CDT 2008


This (on little-endian machine) surprised me:

In [23]:np.ones((1,), dtype='<i2')
Out[23]:array([1], dtype=int16)

In [24]:np.ones((1,), dtype='>i2')
Out[24]:array([256], dtype=int16)

I expected the value to be [1] in either case. Am I wrong?  The 
docstring gives no hint that this is how the dtype argument will be 
interpreted.

In [27]:np.__version__
Out[27]:'1.0.5.dev4958'

Eric


More information about the Numpy-discussion mailing list