Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: newbyteorder docs and typing don't agree on allowed types #26473

Closed
dstansby opened this issue May 18, 2024 · 1 comment · Fixed by #26480
Closed

BUG: newbyteorder docs and typing don't agree on allowed types #26473

dstansby opened this issue May 18, 2024 · 1 comment · Fixed by #26480

Comments

@dstansby
Copy link
Contributor

Describe the issue:

For numpy.dtype.newbyteorder, https://numpy.org/doc/stable/reference/generated/numpy.dtype.newbyteorder.html lists allowable arguments as:

  • ‘S’ - swap dtype from current to opposite endian
  • {‘<’, ‘little’} - little endian
  • {‘>’, ‘big’} - big endian
  • {‘=’, ‘native’} - native order
  • {‘|’, ‘I’} - ignore (no change to byte order)

but the typing doesn't allow 'little', 'big', or 'native':

_ByteOrder = L["S", "<", ">", "=", "|", "L", "B", "N", "I"]

Either the docs should be updated to match the typing, or the typing updated to match the docs.

Reproduce the code example:

import numpy as np
a = np.array([1, 2, 3])
a.dtype.newbyteorder("little")

Error message:

No response

Python and NumPy Versions:

1.26.4
3.12.2 | packaged by conda-forge | (main, Feb 16 2024, 20:54:21) [Clang 16.0.6 ]

Runtime Environment:

No response

Context for the issue:

No response

rgommers added a commit to rgommers/numpy that referenced this issue May 19, 2024
Closes numpygh-26473

[skip circle] [skip cirrus] [skip azp]
@rgommers
Copy link
Member

Agreed, looks like the set of accepted literals missed this by accident. Updating the type annotation in gh-26480.

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

Successfully merging a pull request may close this issue.

2 participants