Drop Python 2 Support, Modernize NumPy/SciPy APIs#123
Drop Python 2 Support, Modernize NumPy/SciPy APIs#123yuxuan-z19 wants to merge 7 commits intoysig:masterfrom
Conversation
|
@yuxuan-z19 Thank you for your pull request! I'm very willing to proceed and pull it. Major Please make the kernels work:
Random walk is a very fundamental kernel to approve me have it work while its failing. Minor updates @yuxuan-z19 :
|
|
@ysig @giannisnik I've investigated the failing tests in The issue stems from As a workaround, I suggest applying a positive semi-definite (PSD) correction by shifting the kernel matrix before normalization. Here is the code snippet implementing this approach: epsilon = 1e-12
min_diag = np.min(X_diag)
if min_diag < 0:
shift = abs(min_diag) + epsilon
km += shift * np.eye(km.shape[0])
X_diag = np.diagonal(km)
out = np.outer(X_diag, X_diag)
out[out == 0] = epsilon
res = km / np.sqrt(np.outer(X_diag, X_diag))This ensures the diagonal entries are all positive before computing the normalization denominator. I will add a new test to verify the correctness and stability of kernel values before and after applying the PSD adjustment on the successful tests in the |
|
@yuxuan-z19 Thank you for locating this.
|
Summary
This PR upgrades GraKeL to support Python 3.8 and above, officially dropping Python 2.x compatibility, which has been end-of-life since January 1, 2020.
In addition:
pyproject.tomlto specify minimum Python version and dependenciesCompatibility
Rationale
Runtime Warnings in Tests
During the upgrade, the following test cases raise
RuntimeWarning: invalid value encountered in sqrtordivide:These warnings may stem from:
They may indicate numerical instability or missing input validation in kernels. Review is requested to: