{"record":{"id":"9c89efff5d23246a","repo":"HKUDS/Vibe-Trading","slug":"model-name-must-be-a-finite-number-got-nume","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/dcf.py","lineNumber":276,"sourceCode":"        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            input here would otherwise flow through the valuation arithmetic\n            and surface as a silently wrong per-share number, which is exactly\n            the outcome the package's no-silent-defaults rule exists to prevent.\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 _validate_weights(equity_weight: float, debt_weight: float, *, model: str) -> None:\n    \"\"\"Check that a pair of capital-structure weights is usable.\n\n    Args:\n        equity_weight: Proposed ``E / (D + E)``.\n        debt_weight: Proposed ``D / (D + E)``.\n        model: Model name for the error message.\n\n    Raises:\n        ValuationError: If either weight is negative, or if they do not sum to\n            1 within :data:`_RECONCILIATION_TOLERANCE`.\n    \"\"\"\n    if equity_weight < 0.0 or debt_weight < 0.0:","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/valuation/dcf.py#L258-L294","documentation":"Raised by _require_finite when the input converts to float but is not finite (NaN, +inf, -inf). Part of the package's no-silent-defaults rule: a NaN would otherwise propagate into a silently wrong per-share number.","triggerScenarios":"Passing float('nan'), float('inf'), or the result of 0.0/0.0 / overflowing computations to any numeric parameter of wacc, fcff_bridge, terminal_value, discount_fcff, equity_bridge, sensitivity_grid.","commonSituations":"Upstream data gaps encoded as NaN (missing rows from pandas); division-by-zero in a preprocessing step feeding the model; JSON parsing 'Infinity' literal.","solutions":["Filter or impute NaN/inf in upstream data before valuation","Guard divisions upstream (denominator zero-checks) so inf never reaches the model","Assert math.isfinite on all derived inputs in a pre-flight validation step"],"exampleFix":"# before\nfcff = row['fcff'] if row else float('nan')\n... discount_fcff(fcff, ...)\n\n# after\nfcff = float(row['fcff']) if row and math.isfinite(row['fcff']) else raise_missing(row)","handlingStrategy":"validation","validationCode":"import math\nassert all(math.isfinite(v) for v in [beta, rfr, erp, pretax_kd]), 'non-finite input'","typeGuard":"def is_finite_number(x) -> TypeGuard[float]:\n    return isinstance(x, (int, float)) and math.isfinite(x)","tryCatchPattern":"try:\n    fcff_bridge(...)\nexcept ValuationError as e:\n    if 'finite' in str(e):\n        row['status'] = 'bad_data'\n        continue","preventionTips":["dropna()/replace([inf,-inf], nan) on DataFrames before valuation","Guard denominators upstream to avoid inf","Treat NaN inputs as data-quality failures, not defaults"],"tags":["valuation","nan","infinity","input-validation"],"backgroundTag":"nan-in-input-data","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}