-
Notifications
You must be signed in to change notification settings - Fork 28.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
[SPARK-21866][ML][PYTHON][FOLLOWUP] Few cleanups and fix image test failure in Python 3.6.0 / NumPy 1.13.3 #19835
Conversation
cc @jkbradley and @imatiach-msft, could you maybe take a look and see if it makes sense? |
Test build #84267 has finished for PR 19835 at commit
|
cbff0fc
to
1581718
Compare
# Running `bytearray(numpy.array([1]))` fails in specific Python versions | ||
# with a specific Numpy version, for example in Python 3.6.0 and NumPy 1.13.3. | ||
# Here, it avoids it by converting it to bytes. | ||
data = bytearray(array.astype(dtype=np.uint8).ravel().tobytes()) |
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.
To be honest, I can't find the exact issue and changes about this issue yet. There are too many similar / related issues in NumPy and Python release notes, and it sounds even harder to find the relevant issue as the exception is from NumPy but the cause seems a different Python version (3.6.0), if I haven't missed something.
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.
strange, but the comment explains the issue well and I think this is a good workaround
Test build #84269 has finished for PR 19835 at commit
|
Test build #84270 has finished for PR 19835 at commit
|
@@ -1836,6 +1836,24 @@ def test_read_images(self): | |||
self.assertEqual(ImageSchema.imageFields, expected) | |||
self.assertEqual(ImageSchema.undefinedImageType, "Undefined") | |||
|
|||
with QuietTest(self.sc): |
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.
nice tests!
the changes look good to me, the extra verification logic for arguments is a great addition |
Merged to master. Thanks for reviewing this @srowen and @imatiach-msft. |
What changes were proposed in this pull request?
Image test seems failed in Python 3.6.0 / NumPy 1.13.3. I manually tested as below:
To be clear, I think the error seems from NumPy - https://github.com/numpy/numpy/blob/75b2d5d427afdb1392f2a0b2092e0767e4bab53d/numpy/core/src/multiarray/number.c#L947
For a smaller scope:
In Python 2.7 / NumPy 1.13.1, it prints:
So, here, I simply worked around it by converting it to bytes as below:
Also, while looking into it again, I realised few arguments could be quite confusing, for example,
Row
that needs some specific attributes andnumpy.ndarray
. I added few type checking and added some tests accordingly. So, it shows an error message as below:How was this patch tested?
Manually tested with
./python/run-tests
.And also: