designspace.space#

designspace.space(*exprs: ParamExpr) Space#

Resolve parameter builders into a Space.

Resolution is where declarations become a checked, immutable object: names are validated, references are bound, the dependency graph is built and cycle-checked, expression types are checked, and charts are constructed. Anything wrong with the declarations raises a ResolutionError here rather than later during sampling, and the message names the offending path.

Parameters:

*exprs (ParamExpr) – The parameter builders to include. Declaration order is preserved in Space.params and is part of the space’s identity: permuting two parameters yields a different fingerprint.

Returns:

The resolved space. Immutable: .forbid(), .freeze(), and the other operations return a new Space rather than mutating this one.

Return type:

Space

Raises:

ResolutionError – If any declaration is invalid: a duplicate or malformed name, a reference to an undeclared parameter, a dependency cycle, a type-incorrect expression, or a degenerate domain.

Examples

>>> s = ds.space(
...     ds.param("algorithm").categorical("greedy", "exact"),
...     ds.param("timeout").real(0.1, 60.0).log_scale(),
... )
>>> list(s.params)
['algorithm', 'timeout']

A bad declaration fails here, naming the path:

>>> ds.space(ds.param("k").integer(10, 1))
Traceback (most recent call last):
    ...
designspace.errors.ResolutionError: param 'k': lo=10 > hi=1