{"record":{"id":"bcac9920a6eb5eb1","repo":"HKUDS/Vibe-Trading","slug":"model-expected-an-assumption-named-expected-na","errorCode":null,"errorMessage":"{model}: expected an Assumption named {expected_name!r}, got {value.name!r}; check that assumptions were not passed under swapped keys.","messagePattern":"(.+?): expected an Assumption named (.+?), got (.+?); check that assumptions were not passed under swapped keys\\.","errorType":"exception","errorClass":"ValuationError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/valuation/dcf.py","lineNumber":218,"sourceCode":"\n    Returns:\n        ``value``, unchanged.\n\n    Raises:\n        ValuationError: If ``value`` is not an :class:`Assumption`, or if its\n            ``name`` does not match ``expected_name`` (which usually means two\n            assumptions were passed under swapped keys).\n    \"\"\"\n    if not isinstance(value, Assumption):\n        raise ValuationError(\n            f\"{model}: {expected_name!r} must be supplied as an Assumption(\"\n            f\"name=..., value=..., basis=...) carrying its justification, not \"\n            f\"a bare {type(value).__name__}. A terminal growth rate or exit \"\n            \"multiple chosen without a stated reason is exactly the kind of \"\n            \"silent default this package refuses to make on your behalf.\"\n        )\n    if value.name != expected_name:\n        raise ValuationError(\n            f\"{model}: expected an Assumption named {expected_name!r}, got \"\n            f\"{value.name!r}; check that assumptions were not passed under \"\n            \"swapped keys.\"\n        )\n    return value\n\n\ndef _require_nonnegative(value: float, name: str, model: str) -> float:\n    \"\"\"Check a value that is a signed formula's magnitude, so must be >= 0.\n\n    Args:\n        value: The candidate magnitude.\n        name: Field name for the error message.\n        model: Model name for the error message.\n\n    Returns:\n        ``value`` as a float.\n","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/valuation/dcf.py#L200-L236","documentation":"When an Assumption is supplied but its name does not match the expected parameter name, _require_assumption raises this error — the classic signature of two assumptions passed under swapped keys (e.g. the exit-multiple assumption given to the growth-rate parameter).","triggerScenarios":"run_dcf(terminal_growth_rate=Assumption('exit_multiple', ...), exit_multiple=Assumption('terminal_growth_rate', ...)); or any Assumption whose name literal differs from the keyword it is passed under.","commonSituations":"Keyword/positional mixups when refactoring call sites; building an assumptions dict then unpacking with ** under renamed keys; copy-paste of assumption blocks between parameters.","solutions":["Swap the two Assumption objects so each keyword receives the matching name.","Construct assumptions with the exact parameter-name string (terminal_growth_rate / exit_multiple).","Prefer **{'terminal_growth_rate': assumption, ...} keyed by parameter name to avoid drift."],"exampleFix":"# before\nrun_dcf(inputs,\n        terminal_growth_rate=Assumption('exit_multiple', 11.0, 'peer median EV/EBITDA'),\n        exit_multiple=Assumption('terminal_growth_rate', 0.02, 'GDP proxy'))\n\n# after\nrun_dcf(inputs,\n        terminal_growth_rate=Assumption('terminal_growth_rate', 0.02, 'GDP proxy'),\n        exit_multiple=Assumption('exit_multiple', 11.0, 'peer median EV/EBITDA'))","handlingStrategy":"validation","validationCode":"assert terminal_growth_rate.name == 'terminal_growth_rate'\nassert exit_multiple.name == 'exit_multiple'","typeGuard":"def assumption_named(a, name):\n    return getattr(a, 'name', None) == name","tryCatchPattern":"except ValuationError as e:\n    if 'swapped keys' in str(e):\n        swap_assumptions_and_retry()","preventionTips":["Name Assumption objects exactly after the keyword they fill","Pass assumptions via **dict keyed by parameter name"],"tags":["valuation","dcf","assumption","swapped-arguments"],"backgroundTag":"swapped-function-arguments","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}