Skip to content

Represent byte order #227

Description

@jdmarble

I work with data that is sometimes in non-native byte order. It looks like byte order can not yet be represented in a DataShape. I can get around this by using side channels like the keyword arguments in odo functions, but it would be more convenient to have byte order information as part of the shape.

Current Behavior

>>> ds.discover(np.array([1], dtype='u4'))
dshape("1 * uint32")
>>> ds.discover(np.array([1], dtype='=u4'))
dshape("1 * uint32")
>>> ds.discover(np.array([1], dtype='<u4'))
dshape("1 * uint32")
>>> ds.discover(np.array([1], dtype='>u4'))
dshape("1 * uint32")

Desired Behavior

One way to do this would be to mirror Numpy and default to the system byte order. This is being run on a little-endian system.

>>> ds.discover(np.array([1], dtype='u4'))
dshape("1 * uint32")
>>> ds.discover(np.array([1], dtype='=u4'))
dshape("1 * uint32")
>>> ds.discover(np.array([1], dtype='<u4'))
dshape("1 * uint32")
>>> ds.discover(np.array([1], dtype='>u4'))
dshape("1 * >uint32")

Numpy's behavior for reference:

>>> np.dtype('u4')
dtype('uint32')
>>> np.dtype('=u4')
dtype('uint32')
>>> np.dtype('<u4')
dtype('uint32')
>>> np.dtype('>u4')
dtype('>u4')

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions