import numpy as np

import martensite_utils.message_pb2 as message_pb2


def numpy_to_proto(array: np.ndarray) -> message_pb2.NDArrayProto():
    proto_message = message_pb2.NDArrayProto()

    proto_message.shape.extend(array.shape)
    proto_message.data = array.tobytes()
    proto_message.dtype = str(array.dtype)
    return proto_message
