import base64


def pack_numpy_array(arr, name):
    """pack numpy array into json-serializable base64 encoded string"""
    return {'name': name, 'dtype': str(arr.dtype), 'size': arr.shape, 'type': 'numpy', 'contents': str(base64.b64encode(arr.data))[2:-1]}