Skip to content

ShaperMetrics ​

python
ShaperMetrics(context: RewardShapingContext, metric_namespace: str) -> None

Owns the scalar, averaged, and per-episode metric-accumulation state for one reward shaper.

Initialize the metrics helper.

Parameters:

  • context (RewardShapingContext) – Shared shaping runtime context.
  • metric_namespace (str) – The owning shaper's metric namespace.

Source

Methods ​

add_averaged_metric ​

python
add_averaged_metric(name: str, value: float) -> None

Log a shaper-specific averaged metric.

The value is buffered and written out at the step passed to the next flush.

Parameters:

  • name (str) – The metric name suffix.
  • value (float) – The metric value.

Source

add_episode_metric ​

python
add_episode_metric(name: str, env_id: int, value: float) -> None

Accumulate a shaper-specific metric to be logged once per episode.

Parameters:

  • name (str) – The episode metric name suffix.
  • env_id (int) – The environment ID.
  • value (float) – The value to add to the episode total.

Source

add_scalar_metric ​

python
add_scalar_metric(name: str, value: float) -> None

Log a shaper-specific scalar metric.

The value is buffered and written out at the step passed to the next flush.

Parameters:

  • name (str) – The metric name suffix.
  • value (float) – The metric value.

Source

flush ​

python
flush(step: int) -> None

Emit any throttled scalar and averaged metrics accumulated since the last flush.

Parameters:

  • step (int) – The step at which to log.

Source

flush_episode_metrics ​

python
flush_episode_metrics(env_id: int) -> None

Emit and clear accumulated episode metrics for one environment.

Parameters:

  • env_id (int) – The environment ID.

Source

metadata_key ​

python
metadata_key(name: str) -> str

Build a namespaced learner-metadata key for this shaper.

Parameters:

  • name (str) – The metadata name suffix.

Returns:

  • str – The full metadata key.

Source

reset_episode_metrics ​

python
reset_episode_metrics(env_id: int) -> None

Clear any accumulated episode metrics for one environment.

Parameters:

  • env_id (int) – The environment ID.

Source