HyukjinKwon commented on a change in pull request #23484: 
[SPARK-26559][ML][PySpark] ML image can't work with numpy versions prior to 1.9
URL: https://github.com/apache/spark/pull/23484#discussion_r245600938
 
 

 ##########
 File path: python/pyspark/ml/image.py
 ##########
 @@ -190,7 +190,13 @@ def toImage(self, array, origin=""):
         # 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())
+        numpy_version = np.__version__.split('.')
+        numpy_version_major = int(numpy_version[0])
+        numpy_version_minor = int(numpy_version[1])
+        if numpy_version_major > 1 or (numpy_version_major == 1 and 
numpy_version_minor >= 9):
 
 Review comment:
   @viirya, not a big deal but I think using `LooseVersion` would be preferred

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to