API reference#
Every name designspace exports, grouped by purpose. The pages are generated
from the docstrings, so they carry the same text help() returns.
Building a space#
The entry points, and the builder view a parameter takes on once its type is chosen.
|
A boolean parameter, declared by .bool(). |
|
An unordered choice among values, declared by .categorical(). |
|
A branch among alternatives, declared by .choice(). |
|
.code()'s return type, a thin leaf view, always non-generative. |
|
.custom()'s return type, a thin leaf view. |
|
What ds.param(name) returns: a parameter with no type chosen yet. |
|
An integer parameter, declared by .integer(). |
|
.repeat()'s return type; re-offers .repeat() (inherited from TypedParamExpr) for nested/variadic lifts. |
|
An ordered choice among values, declared by .ordinal(). |
|
A parameter, either being declared or being referred to. |
|
An ordering of items, declared by .permutation(). |
|
A continuous parameter, declared by .real(). |
|
A resolved design space: the set of configurations you can draw from. |
|
A named group of parameters, declared by .space(). |
|
A selection of items, declared by .subset(). |
|
.symbolic()'s return type, a thin leaf view, mirroring CustomParamExpr. |
|
A parameter whose type has been chosen. |
|
Begin declaring a parameter called name. |
|
Resolve parameter builders into a Space. |
Expressions#
Conditions, constraints, and derived quantities. Expressions are values: they can be built, passed around, and walked through .kind and .children.
An expression node that evaluates to a scalar (numeric or otherwise) value. |
|
An expression node that evaluates to a (Kleene) truth value. |
|
An expression: the shared base of conditions and arithmetic. |
|
|
ds.param("c").prop(name): a custom type's declared scalar property (int/float/bool/str only). |
|
ds.value(fn, *operands, returns=type): an opaque derived quantity: .prop() generalized from one custom param, named property to any operands, arbitrary function. |
|
Combine conditions with and. |
|
Combine conditions with or. |
|
How many of exprs are true, as a number. |
|
Compute a derived quantity with your own function. |
Working with configs#
Reshaping a config without going through a space.
|
What changed between two configurations. |
|
Both the variant name and its payload, in one call. |
|
Turn a nested configuration into one keyed by path. |
|
Whether a configuration is already keyed by path. |
|
The parameters carried by a choice parameter's selected variant. |
|
Rebuild a nested configuration from one keyed by path. |
|
Which variant a choice parameter selected. |
Rendering#
Every public object renders itself for a person through str(). pretty
prints a configuration read against its space.
|
Render obj for a person to read. |
Sampling and validation results#
What the sampling and checking surfaces hand back.
|
One constraint evaluated against one configuration. |
|
One SamplingReport.constraints row. |
|
One difference between two configurations, from ds.config_diff(). |
|
One parameter's value rejected during validation. |
|
What Space.evaluate_partial() found: the state of a partial configuration. |
|
What Space.sampling_report(n, seed, tighten_bounds) returns. |
|
One nested region of a space, from Space.subspaces. |
|
What Space.validate() found. |
Identity and serialization#
Fingerprints identify spaces; config hashes identify points in one.
|
A stable digest identifying one configuration. |
The representation layer#
A Representation is the Space to Space morphism between a genotype and its phenotype.
|
The genotype for one param. |
|
A Space → Space morphism carrying a value-level decode/encode pair. |
|
What Representation.check() found: a report, never an exception. |
|
One law Representation.check() found violated. |
The IR#
The resolved form. Every introspection surface hands back these types, and they are what a solver walks.
The two truth values, declared by .bool(). |
|
|
An unordered set of values, declared by .categorical(). |
|
A monotone map from [0, 1] onto a parameter's domain. |
|
A branch among named variants, declared by .choice(). |
|
Freeform source code, declared by .code(). |
|
When one parameter is active, as resolved IR. |
|
A restriction on which configurations are valid, as resolved IR. |
|
A consumer-supplied type, declared by .custom(). |
Represent a PEP 604 union type |
|
|
A range of integers, declared by .integer(). |
|
What an integer parameter may still take, given a partial configuration. |
|
A list of independent copies, declared by .repeat(). |
|
An ordered set of values, declared by .ordinal(). |
|
One resolved parameter: the introspection surface. |
An ordering of all items, declared by .permutation(). |
|
What a permutation parameter may still order. |
|
|
A grid restricting a numeric domain, set by .quantized(). |
|
A continuous interval, declared by .real(). |
|
What a real parameter may still take, given a partial configuration. |
Represent a PEP 604 union type |
|
A named group of parameters, declared by .space(). |
|
|
A selection of items, declared by .subset(). |
|
What a subset parameter may still select, given a partial configuration. |
|
A symbolic expression tree, declared by .symbolic(). |
|
What a bool, categorical, ordinal, or choice parameter may still take. |
Turn a resolved parameter back into a builder. |
|
|
Build a Space directly from IR, bypassing the builders. |
Support types#
Priors, program-parameter vocabulary, and the custom-type protocols.
|
A range of real constants admissible in a .symbolic() tree. |
|
A range of integer constants admissible in a .symbolic() tree. |
A logarithmic prior: equal weight per order of magnitude. |
|
A logit prior: weight concentrated toward both ends of (0, 1). |
|
|
The full .custom(param_type) protocol. |
A power prior: u ** p weighting toward one end of the domain. |
|
|
An operator declared for a .symbolic() parameter, with its arity. |
|
A distribution you supply yourself, for .prior(). |
Represent a PEP 604 union type |
|
|
The interface a .symbolic() or .code() parameter must satisfy. |
|
Relative weights over a discrete parameter's values. |
Errors#
Every error designspace raises names the offending definition path.
Base of the designspace exception taxonomy. |
|
Raised when a declaration cannot be resolved into a space. |
|
Raised when a draw cannot be produced. |
|
Raised when a space cannot be written out or read back. |
Type aliases#
The names the public signatures are written in. Each is exactly the spelling shown. They carry no behaviour, and exist so that a signature can be followed to a definition instead of guessed at.
- designspace.Config = dict[str, Any]#
A configuration: one point of a space, keyed by instance path. Values are in phenotype form; inactive parameters are absent rather than null.
- designspace.Seed = int | numpy.random.Generator | None#
What every sampling surface accepts as its source of randomness. An int seeds reproducibly, a Generator is used as given, None draws fresh entropy.
- designspace.OnUnserializable = Literal["raise", "mark", "drop"]#
What to_json does with something it cannot serialize.
- designspace.FingerprintScope = Literal["full", "sampling"]#
Which facts a fingerprint covers: document identity, or what fixes the feasible set and the sampling measure.
- designspace.FingerprintUnserializable = Literal["raise", "mark"]#
As OnUnserializable, minus drop, because dropping a site would change what is being identified.