You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
eric-wieser
changed the title
vstack loses endinness
np.concatenate loses endianness / byte order
Dec 12, 2017
I am not convinced we should attempt to preserve this. Although concatenate now has a dtype argument, and the stack could/should inherit that. That would give users a way to work around it if they really care about byte-order.
As mentioned in gh-21319: There is a bit more discussion around this topic in #15088. I do think for np.result_type "canonicalizing" the dtype makes sense. For concatenate, I agree there could be an argument against it. But I still think that unless you happen to write anything to do with serialization you are better off with the canonicalizing behaviour anyway.
So right now, it seems to me that preserving byte-order would really only benefit very few users who probably need to double check a lot of things anyway.
If htere is anyone much in favor of changing it, they should champion this change and argue for it. Until then, this is unlikely to be changed.
It seems to me that the result of vstack does not inherit Endianness from the function parameters correctly.
Example:
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.
The text was updated successfully, but these errors were encountered: