{"record":{"id":"cbd89e3887c6aa2b","repo":"HKUDS/Vibe-Trading","slug":"model-name-must-be-a-finite-number-got-nume-cbd89e","errorCode":null,"errorMessage":"{model}: {name} must be a finite number, got {numeric!r}","messagePattern":"(.+?): (.+?) must be a finite number, got (.+?)","errorType":"validation","errorClass":"ValuationError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/valuation/threestatement.py","lineNumber":471,"sourceCode":"    Args:\n        value: The candidate value.\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\n    Raises:\n        ValuationError: If the value is not a finite number. A non-finite\n            driver or opening figure would otherwise flow into the projection\n            and surface as a misleading \"did not converge\" error.\n    \"\"\"\n    try:\n        numeric = float(value)\n    except (TypeError, ValueError) as exc:\n        raise ValuationError(f\"{model}: {name} must be a number, got {value!r}\") from exc\n    if not math.isfinite(numeric):\n        raise ValuationError(\n            f\"{model}: {name} must be a finite number, got {numeric!r}\"\n        )\n    return numeric\n\n\ndef _resolve_period_count(drivers: Mapping[str, Sequence[float]]) -> int:\n    \"\"\"Validate every driver sequence shares one non-zero length and return it.\n\n    Args:\n        drivers: The driver mapping already checked by\n            :func:`~src.quantlib.valuation.contracts.require_inputs`.\n\n    Returns:\n        The number of periods to project.\n\n    Raises:\n        ValuationError: If the driver sequences disagree in length, or all are\n            empty.","sourceCodeStart":453,"sourceCodeEnd":489,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/valuation/threestatement.py#L453-L489","documentation":"After successful float coercion, _require_finite rejects NaN and +/-inf values with ValuationError. This guards the three-statement solver: a single non-finite opening balance or driver would poison every downstream period and end in a ConvergenceError or garbage output.","triggerScenarios":"Calling project_three_statement with an opening value or driver entry that is float('nan'), math.inf, or numpy.inf — often from a division by zero or a pandas operation that produced NaN upstream.","commonSituations":"Pipeline data with missing observations forward-filled as NaN; growth rates computed as inf from 0-base revenue; Excel imports of #DIV/0! cells.","solutions":["Trace the field named in the message to its source and fix the NaN/inf-producing step (e.g. zero-base division).","Impute or drop the bad observation before building the drivers dict.","Pre-screen with math.isfinite over all scalars in opening/drivers."],"exampleFix":"# before\nopening = {\"cash\": float('nan'), ...}\n# after\nopening = {\"cash\": 120.0, ...}  # cleaned/imputed value","handlingStrategy":"validation","validationCode":"import math\nassert all(math.isfinite(float(v)) for v in opening.values())\nassert all(math.isfinite(x) for xs in drivers.values() for x in xs)","typeGuard":"def is_finite_scalar(x) -> bool:\n    import math\n    return isinstance(x, (int, float)) and math.isfinite(x)","tryCatchPattern":"except ValuationError as e:\n    if 'finite number' in str(e): scrub_data(e)","preventionTips":["dropna() both opening figures and driver arrays before the call","Guard divisions that produce inf (zero-base growth rates)"],"tags":["valuation","three-statement","nan","infinity"],"backgroundTag":"non-finite-value","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}