## Description
`HRPOpt.optimize()` fails with current SciPy versions because it accesses the private attribute `scipy.cluster.hierarchy._LINKAGE_METHODS`.
## Environment
- PyPortfolioOpt: 1.6.0
- Python: 3.14.6
- SciPy: 1.18.0
- macOS arm64
## Reproduction
```python
import pandas as pd
from pypfopt import HRPOpt
prices = pd.DataFrame(
{
"A": [100, 101, 99, 102, 103],
"B": [100, 98, 101, 100, 104],
"C": [100, 102, 103, 101, 105],
"D": [100, 99, 100, 103, 102],
}
)
returns = prices.pct_change().dropna()
hrp = HRPOpt(returns)
hrp.optimize()
Expected behavior
HRPOpt.optimize() should return portfolio weights for valid linkage methods.
Actual behavior
The call raises:
AttributeError:
module 'scipy.cluster.hierarchy' has no attribute '_LINKAGE_METHODS'
The error occurs during linkage-method validation before the portfolio is optimized.
Impact
HRP optimization fails with current SciPy versions, causing HRP-related tests to fail.
Pull request intention
I would like to submit a pull request that replaces this private SciPy API usage with a compatible validation approach and adds regression tests for the supported linkage methods.
Expected behavior
HRPOpt.optimize()should return portfolio weights for valid linkage methods.Actual behavior
The call raises:
The error occurs during linkage-method validation before the portfolio is optimized.
Impact
HRP optimization fails with current SciPy versions, causing HRP-related tests to fail.
Pull request intention
I would like to submit a pull request that replaces this private SciPy API usage with a compatible validation approach and adds regression tests for the supported linkage methods.