ezmsg.sigproc.util.segment#

Segment numbering and config_id for an output fed by more than one input, or reshaped by its stage.

Functions

async next_pair(state)[source]#

The next (a, b) for a two-input unit to combine, taken from state.queue_a and state.queue_b.

Messages pair in arrival order, except one with no samples (an end-of-stream message): that is paired with a zero-length copy of the other input’s previous message instead, so the unit emits one empty output in the new segment. Before the other input has sent anything there is nothing to base that output on, and the message only updates state.segments. state also needs held_a, last_a and last_b, all initially None.

Return type:

tuple[AxisArray, AxisArray]

Classes

class ConfigChain(*own)[source]#

Bases: object

Derives the config_id of a single input’s output, for a stage whose contribution is fixed.

The id is chain_config_id(config_id, *own), recomputed only when the input’s config_id changes, so a steady stream costs one comparison per message. An undeclared input (0) gives an undeclared output. Build a new one wherever own changes (for a stateful stage: at reset).

__init__(*own)[source]#
Return type:

None

update(config_id)[source]#

Return the output’s config_id for this input id.

Parameters:

config_id (int)

Return type:

int

class ConfigJoin[source]#

Bases: object

Derives the config_id of an output that combines several inputs, or whose layout its stage changes.

The id is chain_config_id(*config_ids, *own), recomputed only when an input’s config_id or own (whatever the stage itself contributes to the output layout) changes. If any input does not declare one (0), neither does the output.

__init__()[source]#
Return type:

None

update(*config_ids, own=())[source]#

Return the output’s config_id for these inputs’ ids.

Parameters:
Return type:

int

class SegmentJoin[source]#

Bases: object

Numbers the segments of an output that combines several inputs.

The output starts a new segment whenever any input’s segment changes. Its number is this counter’s own, starting at 0, not any input’s: two inputs’ counters cannot be merged into one, only their changes can.

__init__()[source]#
Return type:

None

update(**segments)[source]#

Record each named input’s current segment; start a new output segment and return True if any changed.

Parameters:

segments (int)

Return type:

bool

class SettingsConfigChain[source]#

Bases: object

Mixin for a stateless transformer whose settings decide how it changes the output layout.

Stamp self._chained_config_id(message) on the output, and return from _config_own() what determines that change. The derived id is cached on the input’s config_id and dropped on a settings change: update_settings calls _request_reset, otherwise a no-op on a stateless processor.