invariance_status = "❌ Non-canonical"
invariance_note = f"Total shaping = {total_shaping:.6f} (non-zero)"
- # Summarize PBRS invariance (added explicit section)
+ # Summarize PBRS invariance
f.write("**PBRS Invariance Summary:**\n\n")
f.write("| Field | Value |\n")
f.write("|-------|-------|\n")
transform_dur_key: str,
non_finite_key: str,
) -> float:
- """Generic helper for (pnl, duration) bi-component transforms.
-
- Consolidates duplicated logic across hold potential & additives.
- """
+ """Generic helper for (pnl, duration) bi-component transforms."""
scale = _get_float_param(params, scale_key, 1.0)
gain = _get_float_param(params, gain_key, 1.0)
transform_pnl = _get_str_param(params, transform_pnl_key, "tanh")
sys.exit(1)
-# --- Helper factories (DRY for contexts and params) ---
def base_params(**overrides) -> dict:
"""Return a fresh copy of DEFAULT_MODEL_REWARD_PARAMETERS with overrides applied.
def test_different_exit_attenuation_modes(self):
"""Test different exit attenuation modes (legacy, sqrt, linear, power, half_life)."""
- # Use canonical constant (includes legacy) instead of hardcoded literals
modes = ATTENUATION_MODES_WITH_LEGACY
for mode in modes:
"""Exit factor must not be negative when pnl >= 0 (invariant clamp)."""
params = self.DEFAULT_PARAMS.copy()
- # Try multiple modes / extreme params
# All canonical modes + legacy + synthetic plateau variant
modes = list(ATTENUATION_MODES_WITH_LEGACY) + ["plateau_linear"]
base_factor = self.TEST_BASE_FACTOR
f"Missing PBRS parameter: {param}",
)
- # --- End of structural PBRS tests (legacy sum test removed) ---
-
def test_pbrs_progressive_release_decay_clamped_zero_current(self):
"""progressive_release with decay>1 clamps to 1 (full release to 0).