optiwindnet.terse ================= .. py:module:: optiwindnet.terse .. autoapi-nested-parse:: Compact, self-describing encodings of solution and routeset links. Module Contents --------------- .. py:class:: LinkScope Bases: :py:obj:`enum.StrEnum` Graph layer represented by :class:`TerseLinks`. Initialize self. See help(type(self)) for accurate signature. .. py:attribute:: TOPOLOGY .. py:attribute:: ROUTESET .. py:class:: TerseLinks Bases: :py:obj:`collections.abc.Sequence`\ [\ :py:obj:`int`\ ] Compact links plus the metadata needed to reconstruct their graph. ``RADIAL`` and ``BRANCHED`` values use one parent target per non-root node. ``RINGED`` values use the flattened route representation. A topology value represents ``S``; a routeset value additionally carries the clone mapping needed to reproduce ``G`` against its location graph. Either scope can be bound to an exact location geometry with ``nodeset_digest``. .. py:attribute:: links :type: tuple[int, Ellipsis] .. py:attribute:: topology :type: optiwindnet.types.Topology .. py:attribute:: scope :type: LinkScope .. py:attribute:: T :type: int .. py:attribute:: R :type: int .. py:attribute:: B :type: int :value: 0 .. py:attribute:: C :type: int :value: 0 .. py:attribute:: D :type: int :value: 0 .. py:attribute:: clone2prime :type: tuple[int, Ellipsis] :value: () .. py:attribute:: nodeset_digest :type: bytes | None :value: None .. py:method:: __post_init__() .. py:method:: __len__() -> int .. py:method:: __iter__() -> collections.abc.Iterator[int] .. py:method:: __getitem__(index) .. py:method:: __array__(dtype=None, copy=None) -> numpy.ndarray .. py:method:: __repr__() -> str .. py:method:: tolist() -> list[int] Return the encoded links as a plain list. .. py:method:: to_dict() -> dict[str, Any] Return a versioned representation suitable for JSON serialization. .. py:method:: from_dict(data: collections.abc.Mapping[str, Any]) -> TerseLinks :classmethod: Restore a value created by :meth:`to_dict`. .. py:method:: from_topology(S: networkx.Graph, *, nodeset_digest: bytes | None = None) -> TerseLinks :classmethod: Encode solution topology ``S``, optionally bound to a node set. .. py:method:: from_routeset(G: networkx.Graph) -> TerseLinks :classmethod: Encode routed solution ``G``, including its clone mapping. .. py:method:: from_array(links: collections.abc.Sequence[int], *, topology: optiwindnet.types.Topology | str | None = None, R: int | None = None, T: int | None = None) -> TerseLinks :classmethod: Adapt a legacy topology array to a self-describing value. .. py:method:: to_topology(**graph_attrs) -> networkx.Graph Reconstruct topology ``S``. .. py:method:: to_routeset(L: networkx.Graph, **graph_attrs) -> networkx.Graph Reconstruct routeset ``G`` against location graph ``L``.