Skip to content

Family schemas

The keyword schemas a distribution-family call in QVR source must match.

family_schemas

Keyword schemas for QVR distribution-family construction.

A family call matches one complete schema. Most families have one canonical schema supplied by their registry record; families with mutually exclusive parameterizations declare each alternative here.

FAMILY_ALIASES module-attribute

FAMILY_ALIASES: dict[str, str] = {'Pushforward': 'Transformed', 'Truncate': 'Restrict'}

Surface family names that resolve to another family's registry record.

A key is a name a source may write; its value is the family whose specification builds the distribution.

DISTRIBUTION_FAMILIES module-attribute

DISTRIBUTION_FAMILIES: frozenset[str] = frozenset((*_FAMILY_PARAMETERS, *FAMILY_ALIASES))

Every distribution-family name accepted in QVR source.

Highlighters consume this set so their surface vocabulary follows the same schemas used by validation and lowering.

family_parameterizations

family_parameterizations(family: str, canonical: tuple[str, ...]) -> tuple[tuple[str, ...], ...]

Return every complete keyword schema accepted by family.

PARAMETER DESCRIPTION
family

The family name as written in source.

TYPE: str

canonical

The parameter names the family's registry record declares, used when no schema for family is declared here.

TYPE: tuple[str, ...]

RETURNS DESCRIPTION
tuple[tuple[str, ...], ...]

One tuple of keyword names per accepted parameterization, empty when the family takes no parameters.

Source code in src/quivers/dsl/family_schemas.py
def family_parameterizations(
    family: str, canonical: tuple[str, ...]
) -> tuple[tuple[str, ...], ...]:
    """Return every complete keyword schema accepted by ``family``.

    Parameters
    ----------
    family : str
        The family name as written in source.
    canonical : tuple[str, ...]
        The parameter names the family's registry record declares,
        used when no schema for ``family`` is declared here.

    Returns
    -------
    tuple[tuple[str, ...], ...]
        One tuple of keyword names per accepted parameterization, empty
        when the family takes no parameters.
    """
    alternatives = _ALTERNATIVE_SCHEMAS.get(family)
    if alternatives is not None:
        return alternatives
    parameters = _FAMILY_PARAMETERS.get(family, canonical)
    return (parameters,) if parameters else ()

family_parameter_names

family_parameter_names(family: str) -> tuple[str, ...] | None

Return the canonical QVR keyword order for family.

PARAMETER DESCRIPTION
family

The family name as written in source.

TYPE: str

RETURNS DESCRIPTION
tuple[str, ...] | None

The keyword names in canonical order, or None when no keyword schema is declared for family.

Source code in src/quivers/dsl/family_schemas.py
def family_parameter_names(family: str) -> tuple[str, ...] | None:
    """Return the canonical QVR keyword order for ``family``.

    Parameters
    ----------
    family : str
        The family name as written in source.

    Returns
    -------
    tuple[str, ...] | None
        The keyword names in canonical order, or None when no keyword
        schema is declared for ``family``.
    """
    return _FAMILY_PARAMETERS.get(family)

render_parameterizations

render_parameterizations(schemas: tuple[tuple[str, ...], ...]) -> str

Render schemas compactly for diagnostics.

Source code in src/quivers/dsl/family_schemas.py
def render_parameterizations(schemas: tuple[tuple[str, ...], ...]) -> str:
    """Render schemas compactly for diagnostics."""
    return " or ".join("(" + ", ".join(schema) + ")" for schema in schemas)