Skip to content

catalog

List the model factories for the builder page.

ListedParam

Bases: TypedDict

One factory argument the builder page can edit.

choices is present when kind is choice. minimum is present when kind is integer. default is the text that fills the chip. An empty edges default means the chain preset. disables names the other fields this one locks once its text leaves that default.

Source code in shadowsim/models/catalog.py
class ListedParam(TypedDict):
    """One factory argument the builder page can edit.

    ``choices`` is present when ``kind`` is ``choice``. ``minimum`` is present
    when ``kind`` is ``integer``. ``default`` is the text that fills the chip.
    An empty ``edges`` default means the chain preset. ``disables`` names the
    other fields this one locks once its text leaves that default.
    """

    name: str
    label: str
    kind: Literal["number", "integer", "choice", "edges", "number_or_list"]
    default: str
    choices: NotRequired[list[str]]
    minimum: NotRequired[int]
    disables: NotRequired[list[str]]

ListedModel

Bases: TypedDict

Display record for one model factory.

Source code in shadowsim/models/catalog.py
class ListedModel(TypedDict):
    """Display record for one model factory."""

    id: str
    title: str
    detail: str
    phrase: str
    setup: str
    qubits: bool
    params: list[ListedParam]

ListedModelTerm

Bases: ListedModel

A Hamiltonian or Lindblad block that can be added beside a model factory.

Source code in shadowsim/models/catalog.py
class ListedModelTerm(ListedModel):
    """A Hamiltonian or Lindblad block that can be added beside a model factory."""

    adds: bool
    symbol: str
    stem: str

listed_models

listed_models() -> list[ListedModel]

Return the public model factories in __all__ order.

Classes are omitted. A factory that requires n_qubits is marked so the page can fill that argument from the Qubits setting. params lists the other factory arguments the chip can edit, with defaults filled in.

Returns:

  • list[ListedModel] –

    Models the builder page can offer.

Source code in shadowsim/models/catalog.py
def listed_models() -> list[ListedModel]:
    """Return the public model factories in ``__all__`` order.

    Classes are omitted. A factory that requires ``n_qubits`` is marked so the
    page can fill that argument from the Qubits setting. ``params`` lists the
    other factory arguments the chip can edit, with defaults filled in.

    Returns:
        Models the builder page can offer.
    """
    return _describe_models(models)

listed_model_terms

listed_model_terms() -> list[ListedModelTerm]

Return Hamiltonian and Lindblad blocks in a fixed order.

Each record names the class the block constructs. adds tells the page to keep the chosen model factory when the block is placed.

Returns:

  • list[ListedModelTerm] –

    Operator blocks the builder page can add to a model.

Source code in shadowsim/models/catalog.py
def listed_model_terms() -> list[ListedModelTerm]:
    """Return Hamiltonian and Lindblad blocks in a fixed order.

    Each record names the class the block constructs. ``adds`` tells the page to
    keep the chosen model factory when the block is placed.

    Returns:
        Operator blocks the builder page can add to a model.
    """
    listed: list[ListedModelTerm] = []
    for term_id, title, stem, cls in _TERMS:
        document = inspect.getdoc(cls)
        detail = title if not document else document.split("\n", 1)[0].replace("``", "")
        required = [
            parameter.name
            for parameter in inspect.signature(cls).parameters.values()
            if parameter.default is inspect.Parameter.empty
        ]
        listed.append(
            {
                "id": term_id,
                "title": title,
                "detail": detail,
                "phrase": title,
                "setup": f"{{name}} = {cls.__name__}({', '.join(required)})",
                "qubits": False,
                "params": [],
                "adds": True,
                "symbol": cls.__name__,
                "stem": stem,
            }
        )
    return listed