Read an array from YAML to numpy.

    It reads arrays registered under the tag ``!numpy_array``.

    Use with:

    .. code-block:: python

        >>> yaml = ruamel.yaml.YAML()
        >>> yaml.constructor.add_constructor("!numpy_array", yaml.numpy_from_yaml)

    Note:
        We cannot use ``yaml.register_class`` because it won't register the proper type.
        (It would register the type of the class, rather than of `numpy.ndarray`). Instead,
        we use the above approach to register this method explicitly with the representer.

def numpy_from_yaml(constructor: Constructor, data: ruamel.yaml.nodes.SequenceNode) -> np.ndarray:
    """ Read an array from YAML to numpy.

    It reads arrays registered under the tag ``!numpy_array``.

    Use with:

    .. code-block:: python

        >>> yaml = ruamel.yaml.YAML()
        >>> yaml.constructor.add_constructor("!numpy_array", yaml.numpy_from_yaml)

    Note:
        We cannot use ``yaml.register_class`` because it won't register the proper type.
        (It would register the type of the class, rather than of `numpy.ndarray`). Instead,
        we use the above approach to register this method explicitly with the representer.
    """
    # Construct the contained values so that we properly construct int, float, etc.
    # We just leave this to YAML because it already stores this information.
    values = [constructor.construct_object(n) for n in data.value]
    logger.debug(f"{data}, {values}")
    return np.array(values)