Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions pypfopt/hierarchical_portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,6 @@ def optimize(self, linkage_method="single"):
OrderedDict
weights for the HRP portfolio
"""
if linkage_method not in sch._LINKAGE_METHODS:
raise ValueError("linkage_method must be one recognised by scipy")

Comment on lines -179 to -181

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the precheck entirely. scipy.cluster.hierarchy.linkage() already validates method internally (confirmed by reading scipy's current source: if method not in _LINKAGE_METHODS: raise ValueError(f"Invalid method: {method}"), that dict just isn't exposed as a module attribute anymore. Letting linkage() do its own validation means this doesn't re-break on a future scipy internal refactor.

if self.returns is None:
cov = self.cov_matrix
corr = cov_to_corr(self.cov_matrix).round(6)
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cvxpy>=1.1.19
numpy>=1.0.0
pandas>=0.19
numpy>=1.26.0,<3.0.0
pandas>=1.0.0,<4.0.0
Comment on lines +2 to +3

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also synced requirements.txt's numpy/pandas bounds to match pyproject.toml (numpy>=1.0.0/pandas>=0.19 → numpy>=1.26.0,<3.0.0/pandas>=1.0.0,<4.0.0), found while checking dependency consistency, pip install -r requirements.txt was pulling much older, unsupported versions than the package actually requires.

scikit-base<0.14.0
scikit-learn>=0.24.1
scipy>=1.3.0