Skip to content

Spaces

Spaces define the signal domains that flow between blocks. They describe what kind of data travels through ports in a composition.

Creating Spaces

A Space wraps a set of named dimensions, each backed by a TypeDef:

from gds import space, typedef

Temperature = typedef("Temperature", float)
Humidity = typedef("Humidity", float, constraint=lambda x: 0.0 <= x <= 1.0)

env_space = space("Environment", temperature=Temperature, humidity=Humidity)

Built-in Spaces

Two sentinel spaces are provided for common patterns:

Space Purpose
EMPTY No signals — used for unused port groups (e.g. backward ports on a Mechanism)
TERMINAL Terminal signal — marks the end of a signal chain
from gds import EMPTY, TERMINAL

Spaces in Blocks

Spaces connect to blocks through interfaces. Each block has four port groups, and spaces define the data flowing through them:

from gds import Policy, interface, space, typedef

Command = typedef("Command", float)
Signal = typedef("Signal", float)

cmd_space = space("Command Space", command=Command)
sig_space = space("Signal Space", signal=Signal)

controller = Policy(
    name="Controller",
    interface=interface(
        forward_in=["Signal"],
        forward_out=["Command"],
    ),
)

Registering Spaces

Spaces are registered with GDSSpec for semantic validation:

from gds import GDSSpec

spec = GDSSpec(name="My System")
spec.collect(env_space, cmd_space)  # type-dispatched registration

See Also