Commit d6f94257 authored by Richard Bowman's avatar Richard Bowman 🔬
Browse files

Handle memoryview in ndarray_to_json

parent 6ab9c971
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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",