Github user HyukjinKwon commented on a diff in the pull request:
https://github.com/apache/spark/pull/19835#discussion_r153562522
--- 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 --
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.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]