openforcefield.utils.utils.serialize_numpy

openforcefield.utils.utils.serialize_numpy(np_array)[source]

Serializes a numpy array into a JSON-compatible string. Leverages the numpy.save function, thereby preserving the shape of the input array

from https://stackoverflow.com/questions/30698004/how-can-i-serialize-a-numpy-array-while-preserving-matrix-dimensions#30699208

Parameters
np_arrayA numpy array

Input numpy array

Returns
serializedstr

A serialized representation of the numpy array.

shapetuple of ints

The shape of the serialized array