Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix CLA max_sharpe with equal expected returns#740

Open
anmol0705 wants to merge 1 commit into
PyPortfolio:main from
anmol0705:fix-738-cla-equal-returns
Open

Fix CLA max_sharpe with equal expected returns #740
anmol0705 wants to merge 1 commit into
PyPortfolio:main from
anmol0705:fix-738-cla-equal-returns

Conversation

@anmol0705

@anmol0705 anmol0705 commented Jun 21, 2026

Copy link
Copy Markdown

Description

Fixes #738.

This fixes a TypeError in CLA.max_sharpe() when all expected returns are equal.

In this edge case, _compute_lambda() can return None for lam, but _solve() later compares lam against floats. This PR applies the existing CLA._infnone() helper consistently in the lambda comparison path, allowing the algorithm to fall through deterministically to the minimum-volatility solution.

Changes

Validation

  • uv run --extra dev pytest tests/test_cla.py
  • uv run --with ruff ruff check pypfopt/cla.py tests/test_cla.py
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[BUG] CLA crashes with TypeError and produces non-deterministic results when expected returns are equal

1 participant

AltStyle によって変換されたページ (->オリジナル) /