Inference methods¶
methods
¶
The inference methods an experiment's infer clause can name.
Each method is declared once, as an ExperimentMethod: its name, what it
produces (a run of the entry on the reference machine, or a fit of a
program's posterior), its options with their types and defaults, and how
it is built from them. An experiment names a method and sets some of its
options; the rest take their declared defaults, and the experiment's hash
reads every option after defaults are applied, so writing a default out
does not change the hash. register_method adds a method.
OptionValue
¶
The value of one method option; None for an absent optional bound.
MethodKind
¶
What a method produces: a run of the entry or a fit of a program.
FitBuilder
¶
FitBuilder = Callable[[Mapping[str, OptionValue], int], InferenceMethod[ModelFit]]
Builds a fit method from its options and the experiment's seed.
RunBuilder
¶
RunBuilder = Callable[[Mapping[str, OptionValue]], RunSettings]
Builds a run's settings from its options.
MethodOption
didactic-model
¶
MethodOption(*, name: str, type: Literal['int', 'float', 'bool'], default: OptionValue = None, minimum: float | None = None, description: str = '')
Bases: Model
One option of an inference method.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The option's name in an
TYPE:
|
type
|
Its value type.
TYPE:
|
default
|
The value an experiment that omits it gets; None when the option is an optional bound.
TYPE:
|
minimum
|
The least value it accepts, or None.
TYPE:
|
description
|
What it sets.
TYPE:
|
RunSettings
didactic-model
¶
RunSettings(*, fuel: int | None = None, numbers: NumberDomain = field(default_factory=NumberDomain))
Bases: Model
How a run method invokes the entry on the reference machine.
| PARAMETER | DESCRIPTION |
|---|---|
fuel
|
The step budget, or None for none.
TYPE:
|
numbers
|
The number domain the run computes in.
TYPE:
|
ExperimentMethod
didactic-model
¶
ExperimentMethod(*, name: str, kind: MethodKind, options: tuple[MethodOption, ...] = (), description: str = '', build_run: RunBuilder | None = field(default=None, opaque=True, extras=OPAQUE_BY_IDENTITY), build_fit: FitBuilder | None = field(default=None, opaque=True, extras=OPAQUE_BY_IDENTITY))
Bases: ValueModel
An inference method an experiment can name.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Its name in an
TYPE:
|
kind
|
Whether it runs the entry or fits a program.
TYPE:
|
options
|
Its options.
TYPE:
|
description
|
What it does.
TYPE:
|
build_run
|
For a run method, the settings builder, compared by identity.
TYPE:
|
build_fit
|
For a fit method, the inference method builder, compared by identity.
TYPE:
|
option
¶
option(name: str) -> MethodOption | None
One option by name.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The option's name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
MethodOption | None
|
The option, or None when the method has none of that name. |
Source code in src/quivers/experiments/methods.py
register_method
¶
register_method(method: ExperimentMethod) -> None
Make an inference method nameable in infer clauses.
| PARAMETER | DESCRIPTION |
|---|---|
method
|
The method.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If a method of that name exists, or the method's builder does not match its kind. |
Source code in src/quivers/experiments/methods.py
experiment_method
¶
experiment_method(name: str) -> ExperimentMethod | None
A registered method by name.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The method's name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ExperimentMethod | None
|
The method, or None. |
Source code in src/quivers/experiments/methods.py
experiment_methods
¶
experiment_methods() -> tuple[ExperimentMethod, ...]
Every registered method.
| RETURNS | DESCRIPTION |
|---|---|
tuple[ExperimentMethod, ...]
|
The methods, sorted by name. |