mcframework.stats_engine.FnMetric#

class mcframework.stats_engine.FnMetric[source]#

Bases: Generic[_MetricT]

Lightweight adapter that binds a human-readable name to a metric function.

Parameters:
namestr

Key under which the metric result is stored in StatsEngine.compute().

fncallable()

Function with signature fn(x: ndarray, ctx: StatsContext) -> T.

docstr, optional

Short description displayed by UIs or docs.

Examples

>>> import numpy as np
>>> m = FnMetric("mean", lambda a, ctx: float(np.mean(a)))
>>> m(np.array([1, 2, 3]), StatsContext(n=3))
2.0

Methods

classmethod __new__(*args, **kwargs)#
__init__(name: str, fn: Callable[[ndarray, StatsContext], _MetricT], doc: str = '') None#