Github user imatiach-msft commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19835#discussion_r153689403
  
    --- Diff: python/pyspark/ml/image.py ---
    @@ -146,7 +163,12 @@ def toImage(self, array, origin=""):
                 mode = ocvTypes["CV_8UC4"]
             else:
                 raise ValueError("Invalid number of channels")
    -        data = bytearray(array.astype(dtype=np.uint8).ravel())
    +
    +        # 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())
    --- End diff --
    
    strange, but the comment explains the issue well and I think this is a good 
workaround


---

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

Reply via email to