types ===== .. py:module:: quantify_scheduler.structure.types .. autoapi-nested-parse:: Types that support validation in Pydantic. Pydantic recognizes magic method ``__get_validators__`` to receive additional validators, that can be used, i.e., for custom serialization and deserialization. We implement several custom types here to tune behavior of our models. See `Pydantic documentation`_ for more information about implementing new types. .. _Pydantic documentation: https://docs.pydantic.dev/latest/usage/types/custom/ Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: quantify_scheduler.structure.types.NDArray quantify_scheduler.structure.types.Graph .. py:class:: NDArray(shape, dtype=float, buffer=None, offset=0, strides=None, order=None) Bases: :py:obj:`numpy.ndarray` Pydantic-compatible version of :class:`numpy.ndarray`. Serialization is implemented using custom methods :meth:`.to_dict` and :meth:`.from_dict`. Data array is encoded in Base64. .. py:method:: to_dict() -> dict[str, Any] Convert the array to JSON-compatible dictionary. .. py:method:: from_dict(serialized: collections.abc.Mapping[str, Any]) -> NDArray :classmethod: Construct an instance from a dictionary generated by :meth`to_dict`. :param serialized: Dictionary that has ``"data"``, ``"shape"`` and ``"dtype"`` keys.", where data is a base64-encoded bytes array, shape is a tuple and dtype is a string representation of a Numpy data type. .. py:method:: validate(v: Any) -> NDArray :classmethod: Validate the data and cast from all known representations. .. py:class:: Graph(incoming_graph_data=None, **attr) Bases: :py:obj:`networkx.Graph` Pydantic-compatible version of :class:`networkx.Graph`. .. py:method:: validate(v: Any) -> Graph :classmethod: Validate the data and cast from all known representations.