mcframework.stats_engine.ComputeResult#

class mcframework.stats_engine.ComputeResult[source]#

Bases: object

Result from StatsEngine.compute() with tracking of computation failures.

Attributes:
metricsdict[str, Any]

Successfully computed metric values, keyed by metric name.

skippedlist[tuple[str, str]]

List of (metric_name, reason) pairs for metrics that were skipped.

errorslist[tuple[str, str]]

List of (metric_name, error_message) pairs for metrics that raised errors.

Examples

>>> engine = StatsEngine([FnMetric("mean", mean)])
>>> data = np.array([1.0, 2.0, 3.0])
>>> ctx = StatsContext(n=3)
>>> result = engine.compute(data, ctx)
>>> result.metrics['mean']
2.0
>>> result.skipped
[]

Methods

successful_metrics

Return names of successfully computed metrics.

successful_metrics() set[str][source]#

Return names of successfully computed metrics.

Returns:
set[str]

Set of metric names present in metrics.

classmethod __new__(*args, **kwargs)#
__init__(metrics: dict[str, ~typing.Any], skipped: list[tuple[str, str]] = <factory>, errors: list[tuple[str, str]] = <factory>) None#