designspace.is_flat#
- designspace.is_flat(config: dict[str, Any], space: Space) bool#
Whether a configuration is already keyed by path.
ds.flatten() refuses a configuration in the form it exists to produce, so this asks that question first. Two marks tell the forms apart, and either one settles it: a key below the top level carries a . or a [, which no parameter name may contain, and a lift’s own entry holds a list nested and that list’s length flat.
A configuration carrying neither mark reads the same in both forms, every value sitting at a bare name, and is reported not flat. ds.flatten() accepts it, returning it unchanged.
- Parameters:
- Returns:
Whether the configuration is keyed by path.
- Return type:
Examples
>>> s = ds.space( ... ds.param("n").integer(0, 3), ... ds.param("timeouts").integer(1, 60).repeat(ds.param("n")), ... ) >>> config = {"n": 2, "timeouts": [30, 45]} >>> ds.is_flat(config, s) False >>> ds.is_flat(ds.flatten(config, s), s) True
It reports exactly what ds.flatten() refuses.
>>> ds.flatten(ds.flatten(config, s), s) Traceback (most recent call last): ... TypeError: flatten(): the configuration is already keyed by path, at ...