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

Raise a clearer error when CLA receives a singular covariance matrix#741

Open
Whning0513 wants to merge 1 commit into
PyPortfolio:main from
Whning0513:fix-issue-737
Open

Raise a clearer error when CLA receives a singular covariance matrix #741
Whning0513 wants to merge 1 commit into
PyPortfolio:main from
Whning0513:fix-issue-737

Conversation

@Whning0513

@Whning0513 Whning0513 commented Jun 21, 2026

Copy link
Copy Markdown

Fixes #737.

CLA.max_sharpe() currently lets singular covariance submatrices fall through to np.linalg.inv, which surfaces a raw LinAlgError: Singular matrix from NumPy.

This wraps the CLA matrix inversions in a small helper so the failure becomes a user-facing ValueError that explains the current CLA implementation needs an invertible covariance matrix. I also added a regression test covering a perfectly correlated two-asset covariance matrix.

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 LinAlgError on singular covariance matrices instead of raising a user-facing validation error

1 participant

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