Skip to content

Row-context bindings

Annotate bound values with observation requirements, not function types.

RowContextBinding dataclass

A function argument preserved unchanged alongside its row context.

value instance-attribute

value: T

row_context instance-attribute

row_context: RowContext

time

time(value: T, *, dimension: Dimension | Reference | str, before: str = '0s', after: str = '0s') -> RowContextBinding[T]

Bind a value with preceding/following fixed-time requirements.

Parameters:

Name Type Description Default
value T

The original argument, without conversion to a duration.

required
dimension Dimension | Reference | str

Datetime dimension along which the window is measured.

required
before str

Required preceding duration, or UNBOUNDED.

'0s'
after str

Required following duration, or UNBOUNDED.

'0s'

Returns:

Type Description
RowContextBinding[T]

A binding annotation that is unwrapped during Spec conversion.

Raises:

Type Description
ValueError

If an extent is not a supported fixed duration.

steps

steps(value: T, *, dimension: Dimension | Reference | str, before: CountExtent = 0, after: CountExtent = 0) -> RowContextBinding[T]

Bind a value with integer-coordinate distances, not observation counts.

Parameters:

Name Type Description Default
value T

The unchanged function argument.

required
dimension Dimension | Reference | str

Integer dimension along which distance is measured.

required
before CountExtent

Preceding coordinate distance, or UNBOUNDED.

0
after CountExtent

Following coordinate distance, or UNBOUNDED.

0

Returns:

Type Description
RowContextBinding[T]

The argument annotated with its context requirements.

Raises:

Type Description
ValueError

If a bound is not a nonnegative integer or UNBOUNDED.

rows

rows(value: T, *, before: CountExtent = 0, after: CountExtent = 0) -> RowContextBinding[T]

Bind a value with ordered observation-count requirements.

Parameters:

Name Type Description Default
value T

The unchanged function argument.

required
before CountExtent

Preceding observation count, or UNBOUNDED.

0
after CountExtent

Following observation count, or UNBOUNDED.

0

Returns:

Type Description
RowContextBinding[T]

The argument annotated with its context requirements.

Raises:

Type Description
ValueError

If a bound is not a nonnegative integer or UNBOUNDED.

current

current() -> row_context.RowContext

Declare that only the current observation is required.

all_rows

all_rows() -> row_context.RowContext

Declare that all observations in the input profile are required.