Result Scope

class gpype.frontend.widgets.result_scope.ResultScope[source]

Bases: INode, Widget

Generic result endpoint: a sink a frontend subscribes to.

Makes no assumption about the stream. Where TimeSeriesScope needs a sampling rate and a time axis, this takes whatever arrives – a classifier decision at 4 Hz, a sparse label, a feature vector – and shows the current value per channel. A non-Python frontend subscribes to the same stream and renders it however it likes: this node’s identity is its role in the pipeline, and the Qt readout is one per-residency implementation of that role, not the node itself.

One row per channel: the channel’s name, its current value, and – when history is positive – the values before it.

An INode and a Widget rather than a Scope or an IONode: a readout draws no plot, and a sparse decision stream has no sampling rate, which IONode.setup would refuse.

DEFAULT_DECIMALS = 3

Digits drawn after the decimal point, when the author names none.

DEFAULT_HISTORY = 0

Values kept per channel besides the current one. Zero means the readout shows the latest frame and nothing else.

CAPTION = 'Result'

Caption when the author names the readout nothing.

MIN_DECIMALS = 0

the readout formats with f"{value:.{decimals}f}", and a negative precision raises ValueError from inside the format string on the GUI thread, where the number an author wrote appears nowhere.

Type:

Accepted range for decimals. Bounded rather than trusted

MAX_DECIMALS = 12
MIN_HISTORY = 0

Accepted range for history. The lower bound is what deque(maxlen=...) accepts – a negative maxlen raises. The upper bound is a display bound, not a memory one: past values are drawn as text on one line per channel.

MAX_HISTORY = 1000
class Configuration[source]

Bases: Configuration

Configuration keys for the result readout.

class Keys[source]

Bases: Keys

Required configuration parameter keys.

DECIMALS = 'decimals'

Configuration key for the drawn decimal precision

HISTORY = 'history'

Configuration key for how many past values to draw

__init__(name=None, refresh_rate=None, decimals=3, history=0, timing=None, edge_id=None, **kwargs)[source]

Initialize the result readout widget.

Parameters:
  • name (str) – Optional name for this node. Shown as the widget’s group box caption, and used to refer to the node from a document’s connections.

  • refresh_rate (float) – Repaints per second. Defaults to DEFAULT_REFRESH_RATE.

  • decimals (int) – Digits after the decimal point in the readout.

  • history (int) – Past values shown per channel besides the current one. Zero shows the latest frame only.

  • timing (str) – Timing to give the input port, from Constants.Timing. A result stream may be sparse, and a SYNC port cannot be connected to an ASYNC source (“Ports have incompatible timings”). None leaves the port default alone; ports supplied directly keep their own.

  • edge_id (Optional[str]) – Which edge runs this node, matched against the edge process’s –edge-id. None, the default, is every edge; ignored when the pipeline is not distributed.

  • **kwargs – Additional arguments passed to parent classes.

Raises:
  • RuntimeError – If no Qt application exists yet.

  • ValueError – If decimals or history is outside its range.

setup(data, port_context_in)[source]

Read the stream’s shape, which is a channel count and nothing more.

No sampling rate is read, and that is the point of the class: a classifier decision, a sparse label or an end-of-run summary has no rate, and demanding one would make this scope unusable for exactly the streams it exists for.

Parameters:
  • data (dict[str, ndarray]) – Input data dictionary (not used in setup phase).

  • port_context_in (dict[str, dict]) – Context information for input ports.

Returns:

Updated port context for downstream components.

Return type:

dict[str, dict]

Raises:

ValueError – If the input context declares no channel count.

step(data)[source]

Keep the newest frame, and the tail of it that history shows.

Parameters:

data (dict[str, ndarray]) – Dictionary containing input data arrays from connected ports.

Returns:

Empty dictionary (this is a sink node with no outputs).

Return type:

dict[str, ndarray]