np.concatenate loses endianness / byte order
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 32.8k
- Forks
- 12.8k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 197
Description
It seems to me that the result of vstack does not inherit Endianness from the function parameters correctly.
Example:
a = np.zeros((3,3), dtype='>i2')
print a.dtype
b = np.vstack((a,a))
print b.dtype
The first print gives the correct '>i2' but the second one gives 'uint16' which should mean Little Endinness, since I'm running a 64bit Windows 7 machine.
The problem arose when trying to load and concatenate binary 16 bit pgm images. Pgm stores images in Big Endian, and my routine can read and store the images correctly. It is only when I try to concatenate two images with vstack that the resulting image is corrupted since the byte order gets switched.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported dtype change with np.zeros(dtype='>i2') and np.vstack((a, a)), then compare the result with the input byte order. Trace the np.vstack and concatenation entry points and existing dtype tests; done means concatenating big-endian arrays preserves the expected byte order and the regression is covered by a test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100