CADETProcess.metric_space.Metric

CADETProcess.metric_space.Metric#

class CADETProcess.metric_space.Metric(name: str, n_metrics: int | None = None, dims: tuple[str, ...] | None = None, coords: dict[str, list[Any]] | None = None, labels: list[str] | None = None)[source]#

Bases: object

Declaration of a named output.

Parameters:
namestr

Unique name identifying this metric within a MetricSpace.

n_metricsint, optional

Number of scalar entries. Derived from dims/coords when named dimensions are declared; defaults to 1 (scalar).

dimstuple of str, optional

Named dimensions, e.g. ("component",). Requires coords.

coordsdict, optional

Coordinate values per dimension, e.g. {"component": ["A", "B"]}. Every entry in dims must have coordinates.

labelslist of str, optional

One label per scalar entry. Defaults to name for scalars, to {name}_{coord} for one-dimensional named metrics, and to {name}_{i} otherwise.

property labels: list[str]#

One label per scalar entry.

property shape: tuple[int, ...]#

Declared value shape; () for scalar metrics.

validate(value: Any) ndarray[source]#

Validate value against the declared shape.

Returns the value as np.ndarray with the declared shape. A scalar metric additionally accepts a length-1 vector, which is canonicalized to a 0-d array.

Raises:
ValueError

If the value’s shape does not match the declaration.