Skip to content

elicito.types#

specification of custom types

Classes:

Name Description
ExpertDict

typed dictionary of specification of expert

Hyper

Typed dictionary for specification of hyper

Initializer

typed dictionary for specification of initialization method

MetaSettings

Typed dictionary for specification of meta settings in Elicit

NFDict

Typed dictionary for specification of normalizing flow

Parallel

Typed dictionary for specification of parallelization parallel

Parameter

Class for specification of a parameter, inheriting from dict.

QueriesDict

Typed dictionary for specification of queries

Target

Class for specification of a target, inheriting from dict.

Trainer

typed dictionary for specification of trainer

Uniform

typed dictionary for specification of initialization distribution

ExpertDict #

Bases: TypedDict

typed dictionary of specification of expert

Source code in src/elicito/types.py
class ExpertDict(TypedDict, total=False):
    """
    typed dictionary of specification of [`expert`][elicito.elicit.Expert]
    """

    ground_truth: dict[str, Any]
    num_samples: int
    data: dict[str, list[Any]]

Hyper #

Bases: TypedDict

Typed dictionary for specification of hyper

Source code in src/elicito/types.py
class Hyper(TypedDict):
    """
    Typed dictionary for specification of [`hyper`][elicito.elicit.hyper]
    """

    name: str
    constraint: Callable[[float], tf.Tensor]
    constraint_name: str
    vtype: Callable[[Any], Any]
    dim: int
    shared: bool

Initializer #

Bases: TypedDict

typed dictionary for specification of initialization method

Source code in src/elicito/types.py
class Initializer(TypedDict):
    """
    typed dictionary for specification of initialization method
    """

    method: str | None
    distribution: Uniform | None
    loss_quantile: float | None
    iterations: int | None
    hyperparams: dict[str, Any] | None

MetaSettings #

Bases: TypedDict

Typed dictionary for specification of meta settings in Elicit

See Elicit

Source code in src/elicito/types.py
class MetaSettings(TypedDict):
    """
    Typed dictionary for specification of meta settings in `Elicit`

    See [`Elicit`][elicito.Elicit]
    """

    dry_run: bool

NFDict #

Bases: TypedDict

Typed dictionary for specification of normalizing flow

See network

Source code in src/elicito/types.py
class NFDict(TypedDict):
    """
    Typed dictionary for specification of normalizing flow

    See [`network`][elicito.networks.NF]

    """

    inference_network: Callable[[Any], Any]
    network_specs: dict[str, Any]
    base_distribution: Callable[[Any], Any]

Parallel #

Bases: TypedDict

Typed dictionary for specification of parallelization parallel

See parallel

Source code in src/elicito/types.py
class Parallel(TypedDict):
    """
    Typed dictionary for specification of parallelization `parallel`

    See [`parallel`][elicito.utils.parallel]
    """

    runs: int
    cores: int
    seeds: list[int] | None

Parameter #

Bases: dict[str, Any]

Class for specification of a parameter, inheriting from dict.

Methods:

Name Description
__repr__

Return a readable summary of the object.

__str__

Return a readable summary of the object.

Source code in src/elicito/types.py
class Parameter(dict[str, Any]):
    """Class for specification of a parameter, inheriting from `dict`."""

    def __init__(
        self,
        name: str,
        family: Any,
        hyperparams: dict[str, Hyper] | None,
        constraint_name: str,
        constraint: Callable[[float], float],
    ):
        super().__init__(
            name=name,
            family=family,
            hyperparams=hyperparams,
            constraint_name=constraint_name,
            constraint=constraint,
        )
        self.name: str = name
        self.family: Any = family
        self.hyperparams: dict[str, Hyper] | None = hyperparams
        self.constraint_name: str = constraint_name
        self.constraint: Callable[[float], float] = constraint

    def __str__(self) -> str:
        """Return a readable summary of the object."""
        if self.family is None:
            family_name = "Unknown"
        else:
            family_name = self.family.__name__

        if self.hyperparams is None:
            hypers = ""
        else:
            hypers = ", ".join(
                [f"{k}: {v['name']}" for k, v in self.hyperparams.items()]
            )
        return f"{self.name} ~ {family_name}({hypers})"

    def __repr__(self) -> str:
        """Return a readable summary of the object."""
        return self.__str__()

__repr__ #

__repr__() -> str

Return a readable summary of the object.

Source code in src/elicito/types.py
def __repr__(self) -> str:
    """Return a readable summary of the object."""
    return self.__str__()

__str__ #

__str__() -> str

Return a readable summary of the object.

Source code in src/elicito/types.py
def __str__(self) -> str:
    """Return a readable summary of the object."""
    if self.family is None:
        family_name = "Unknown"
    else:
        family_name = self.family.__name__

    if self.hyperparams is None:
        hypers = ""
    else:
        hypers = ", ".join(
            [f"{k}: {v['name']}" for k, v in self.hyperparams.items()]
        )
    return f"{self.name} ~ {family_name}({hypers})"

QueriesDict #

Bases: TypedDict

Typed dictionary for specification of queries

Source code in src/elicito/types.py
class QueriesDict(TypedDict, total=False):
    """
    Typed dictionary for specification of [`queries`][elicito.elicit.Queries]
    """

    name: str
    value: Any | None
    func_name: str

Target #

Bases: dict[str, Any]

Class for specification of a target, inheriting from dict.

Methods:

Name Description
__repr__

Return a readable summary of the object.

__str__

Return a readable summary of the object.

Source code in src/elicito/types.py
class Target(dict[str, Any]):
    """Class for specification of a target, inheriting from `dict`."""

    def __init__(
        self,
        name: str,
        query: QueriesDict,
        target_method: Callable[[Any], Any] | None,
        loss: Callable[[Any], float],
        weight: float,
    ):
        super().__init__(
            name=name,
            query=query,
            target_method=target_method,
            loss=loss,
            weight=weight,
        )
        self.name: str = name
        self.query: QueriesDict = query
        self.target_method: Callable[[Any], Any] | None = target_method
        self.loss: Callable[[Any], float] = loss
        self.weight: float = weight

    def __str__(self) -> str:
        """Return a readable summary of the object."""
        return (
            f"Target(name={self.name!r}, query={self.query['name']}, "
            f"loss={self.loss.__class__.__name__}, weight={self.weight})"
        )

    def __repr__(self) -> str:
        """Return a readable summary of the object."""
        return self.__str__()

__repr__ #

__repr__() -> str

Return a readable summary of the object.

Source code in src/elicito/types.py
def __repr__(self) -> str:
    """Return a readable summary of the object."""
    return self.__str__()

__str__ #

__str__() -> str

Return a readable summary of the object.

Source code in src/elicito/types.py
def __str__(self) -> str:
    """Return a readable summary of the object."""
    return (
        f"Target(name={self.name!r}, query={self.query['name']}, "
        f"loss={self.loss.__class__.__name__}, weight={self.weight})"
    )

Trainer #

Bases: TypedDict

typed dictionary for specification of trainer

Source code in src/elicito/types.py
class Trainer(TypedDict, total=False):
    """
    typed dictionary for specification of [`trainer`][elicito.elicit.trainer]
    """

    method: str
    seed: int
    B: int
    num_samples: int
    epochs: int
    seed_chain: int
    progress: int

Uniform #

Bases: TypedDict

typed dictionary for specification of initialization distribution

See uniform

Source code in src/elicito/types.py
class Uniform(TypedDict):
    """
    typed dictionary for specification of initialization distribution

    See [`uniform`][elicito.initialization.uniform]

    """

    radius: float | list[float | int]
    mean: float | list[float | int]
    hyper: list[str] | None