From d6f942577ad7b33ae7bc22a9f262a9ecbcbd0f20 Mon Sep 17 00:00:00 2001 From: Richard Bowman Date: Mon, 17 Feb 2020 14:43:59 +0000 Subject: [PATCH] Handle memoryview in ndarray_to_json --- openflexure_microscope/utilities.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openflexure_microscope/utilities.py b/openflexure_microscope/utilities.py index 27e46212..63db1651 100644 --- a/openflexure_microscope/utilities.py +++ b/openflexure_microscope/utilities.py @@ -23,6 +23,10 @@ def serialise_array_b64(npy_arr): def ndarray_to_json(arr: np.ndarray): + if isinstance(arr, memoryview): + # We can transparently convert memoryview objects to arrays + # This comes in very handy for the lens shading table. + arr = np.array(arr) b64_string, dtype, shape = serialise_array_b64(arr) return { "@type": "ndarray",