docs/support/ptypes.py
def touchstone_data(obj):
    r"""
    Validate if an object is an :ref:`TouchstoneData` pseudo-type object.

    :param obj: Object
    :type  obj: any

    :raises: RuntimeError (Argument \`*[argument_name]*\` is not valid). The
     token \*[argument_name]\* is replaced by the name of the argument the
     contract is attached to

    :rtype: None
    """
    if (not isinstance(obj, dict)) or (
        isinstance(obj, dict)
        and (sorted(obj.keys()) != sorted(["points", "freq", "pars"]))
    ):
        raise ValueError(pexdoc.pcontracts.get_exdesc())
    if not (isinstance(obj["points"], int) and (obj["points"] > 0)):
        raise ValueError(pexdoc.pcontracts.get_exdesc())
    if _check_increasing_real_numpy_vector(obj["freq"]):
        raise ValueError(pexdoc.pcontracts.get_exdesc())
    if not isinstance(obj["pars"], np.ndarray):
        raise ValueError(pexdoc.pcontracts.get_exdesc())
    vdata = ["int", "float", "complex"]
    if not any([obj["pars"].dtype.name.startswith(item) for item in vdata]):
        raise ValueError(pexdoc.pcontracts.get_exdesc())
    if obj["freq"].size != obj["points"]:
        raise ValueError(pexdoc.pcontracts.get_exdesc())
    nports = int(math.sqrt(obj["pars"].size / obj["freq"].size))
    if obj["points"] * (nports ** 2) != obj["pars"].size:
        raise ValueError(pexdoc.pcontracts.get_exdesc())
def touchstone_data(obj):
    r"""
    Validate if an object is an :ref:`TouchstoneData` pseudo-type object.

    :param obj: Object
    :type  obj: any

    :raises: RuntimeError (Argument \`*[argument_name]*\` is not valid). The
     token \*[argument_name]\* is replaced by the name of the argument the
     contract is attached to

    :rtype: None
    """
    if (not isinstance(obj, dict)) or (
        isinstance(obj, dict)
        and (sorted(obj.keys()) != sorted(["points", "freq", "pars"]))
    ):
        raise ValueError(pexdoc.pcontracts.get_exdesc())
    if not (isinstance(obj["points"], int) and (obj["points"] > 0)):
        raise ValueError(pexdoc.pcontracts.get_exdesc())
    if _check_increasing_real_numpy_vector(obj["freq"]):
        raise ValueError(pexdoc.pcontracts.get_exdesc())
    if not isinstance(obj["pars"], np.ndarray):
        raise ValueError(pexdoc.pcontracts.get_exdesc())
    vdata = ["int", "float", "complex"]
    if not any([obj["pars"].dtype.name.startswith(item) for item in vdata]):
        raise ValueError(pexdoc.pcontracts.get_exdesc())
    if obj["freq"].size != obj["points"]:
        raise ValueError(pexdoc.pcontracts.get_exdesc())
    nports = int(math.sqrt(obj["pars"].size / obj["freq"].size))
    if obj["points"] * (nports ** 2) != obj["pars"].size:
        raise ValueError(pexdoc.pcontracts.get_exdesc())
r"""
    Validate if an object is an :ref:`TouchstoneData` pseudo-type object.

    :param obj: Object
    :type  obj: any

    :raises: RuntimeError (Argument \`*[argument_name]*\` is not valid). The
     token \*[argument_name]\* is replaced by the name of the argument the
     contract is attached to

    :rtype: None