-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Packing tests #2694
Packing tests #2694
Conversation
From the bigendian machine:
|
It's interesting. I've fixed Could you test the latest commit? |
I'm getting this now:
There's also an ongoing error that's also in the latest releases:
|
@wiredfool What do you think about this in general?
Should be consider |
I think that for any sort of resampling or image ops, it would be completely goofy to store non-native endian in Historically, the native versions were added for integer modes because of libtiff, which returns multibyte pixels in the native format, so it's just a copy operation to add it to storage. Our tiff implementation needed to decode the endianness to get it right. |
For sure. In Pillow objects we store all data only in native order. The question is how to interpret the data from external sources in 'F' and 'I' rawmodes. There are two sources which can contain ramodes:
For me the best solution is align those modes with current rawmode format (where "default is little endian") and add appropriate section in Release Notes. I've installed QEMU with powerpc architecture, it is damn slow but works. I see the error in |
Tests/test_lib_pack.py
Outdated
self.assertRaises(ValueError, lambda: unpack("CMYK", "CMYK", 2)) | ||
def assert_pack(self, mode, rawmode, data, *pixels): | ||
""" | ||
data - eather raw bytes with data or just number of bytes in rawmode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either
Tests/test_lib_pack.py
Outdated
class TestLibUnpack(PillowTestCase): | ||
def assert_unpack(self, mode, rawmode, data, *pixels): | ||
""" | ||
data - eather raw bytes with data or just number of bytes in rawmode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either
Changed packers and unpackers for |
Ok, mostly afk this weekend, but will check on mon. |
(fwiw, my mini is at ~ 70 seconds for a test run, which is roughly equivalent to a raspberry pi) Ok, I get your point now. We should not change the meaning of the
re: "default is little endian" comment There's something of a disconnect between the storage modes, which are limited in number and expressiveness and fixed to native endian and the pack/unpack raw modes, where the flagged details default to LE if not specified. The disconnect comes when there's identically named storage and raw modes with conflicting defaults. There are modes that do what you're proposing, |
You are right, I didn't install numpy.
Ok, reverted. Could you check again? |
Tests/test_lib_pack.py
Outdated
self.assert_pack("I", "I;16B", 2, 0x0102, 0x0304) | ||
self.assert_pack("I", "I;32S", | ||
b'\x83\x00\x00\x01\x01\x00\x00\x83', | ||
0x01000083, -2097151999) | ||
|
||
if sys.byteorder == 'little': | ||
self.assert_pack("I", "I", 4, 0x04030201, 0x08070605) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you missed moving the unpack version of these tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. Done.
Ok, tests are passing here. |
Decided to implement all and improved tests for packing and unpacking.
Added many missed tests. At the end all possible modes should be covered. Most tests improved, for example with line interleave.