Repository navigation
Commit 6844ef0
saket3395
fix: guard None lambda in CLA._solve case-b comparison
Fixes #738. CLA.max_sharpe() raised TypeError: '>' not supported
between instances of 'NoneType' and 'float' whenever all expected
returns were equal.
_compute_lambda returns (None, None) when its denominator c is
exactly zero, which is guaranteed when all expected returns are
identical. The case-a) branch of _solve already guards against this
by comparing CLA._infnone(lam) instead of the raw lam, but the
case-b) branch compared the raw lam directly, causing the crash.
Wraps lam with CLA._infnone(...) in both comparisons of the case-b)
branch, mirroring the existing case-a) pattern. When lam is None this
now resolves to -inf, so the candidate is simply never selected as
i_out/l_out, and the algorithm falls through to the minimum-variance
solution instead of crashing.1 parent a6638d2 commit 6844ef0
1 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
364 | 364 | | |
365 | 365 | | |
366 | 366 | | |
367 | | - | |
368 | | - | |
| 367 | + | |
| 368 | + | |
369 | 369 | | |
370 | 370 | | |
371 | 371 | | |
| |||
0 commit comments