From cf9b16c2c3cc4a19d3debe3c2c42af11dd2b1b18 Mon Sep 17 00:00:00 2001 From: Fanwang Meng Date: Mon, 2 Jan 2023 21:27:07 -0500 Subject: [PATCH 1/4] Drop Python 3.6 and `lgtm` code scanning https://github.blog/2022-08-15-the-next-step-for-lgtm-com-github-code-scanning/ --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 9e78cab6..3c927469 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,12 @@ Procrustes ========== -[![This project supports Python 3.6+](https://img.shields.io/badge/Python-3.6+-blue.svg)](https://python.org/downloads) +[![This project supports Python 3.7+](https://img.shields.io/badge/Python-3.6+-blue.svg)](https://python.org/downloads) [![GPLv3 License](https://img.shields.io/badge/License-GPL%20v3-yellow.svg)](https://opensource.org/licenses/) [![GitHub Actions CI Tox Status](https://github.com/theochem/procrustes/actions/workflows/ci_tox.yml/badge.svg?branch=master)](https://github.com/theochem/procrustes/actions/workflows/ci_tox.yml) [![Documentation Status](https://readthedocs.org/projects/procrustes/badge/?version=latest)](https://procrustes.readthedocs.io/en/latest/?badge=latest) [![codecov](https://codecov.io/gh/theochem/procrustes/branch/master/graph/badge.svg?token=3L96J5QQOT)](https://codecov.io/gh/theochem/procrustes) [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/theochem/procrustes/master?filepath=doc%2Fnotebooks%2F) -[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/theochem/procrustes.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/theochem/procrustes/context:python) The Procrustes library provides a set of functions for transforming a matrix to make it as similar as possible to a target matrix. For more information, visit From 524a43c8603bc1e181fbf432d36d7e1937ba2f6b Mon Sep 17 00:00:00 2001 From: Fanwang Meng Date: Mon, 2 Jan 2023 21:28:26 -0500 Subject: [PATCH 2/4] Drop Python 3.6 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3c927469..73e9d84b 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Dependencies The following dependencies are required to run Procrustes properly, -* Python >= 3.6: +* Python >= 3.7: * NumPy >= 1.21.5: * SciPy >= 1.5.0: * PyTest >= 5.3.4: From 323f2920e5bcef5f288629b85131b06c73505a58 Mon Sep 17 00:00:00 2001 From: Fanwang Meng Date: Mon, 2 Jan 2023 21:36:46 -0500 Subject: [PATCH 3/4] Update virtual environment creation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 73e9d84b..bc40c240 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ first, and then: ```bash # Create and activate myenv conda environment (optional, but recommended) -conda create -n myenv python=3.6 +conda create -n myenv python=3.7 conda activate myenv # Install the stable release. From 64f55d172934459627dbe2f5a33faee40ba1d34d Mon Sep 17 00:00:00 2001 From: Fanwang Meng Date: Mon, 2 Jan 2023 21:52:34 -0500 Subject: [PATCH 4/4] Clean docstring --- procrustes/psdp.py | 39 ++++++++++++++++----------------------- requirements.txt | 2 +- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/procrustes/psdp.py b/procrustes/psdp.py index 92d160ec..6eb75836 100644 --- a/procrustes/psdp.py +++ b/procrustes/psdp.py @@ -20,7 +20,7 @@ # along with this program; if not, see # # -- -"""Positive semidefinite Procrustes Module.""" +"""Positive semi-definite Procrustes Module.""" from math import inf, sqrt from typing import Dict, Optional @@ -75,20 +75,20 @@ def psdp_projgrad( b : np.ndarray The target matrix :math:`\mathbf{B}`. - options : Dict, optional + options_dict : Dict, optional Dictionary with fields that serve as parameters for the algorithm. max_iter : int Maximum number of iterations. - Default value is 10000. + Default=10000. s_tol : float Stop control for ||S_i - S_{i-1}||_F / ||S_1 - S_0||_F - Defaut value is 1e-5. Should be kept below 1 + Defaut=1e-5. Should be kept below 1 f_tol : float Stop control for ||F_i - F_{i-1}||_F/(1+||F_{i-1}||_F). - Default value is 1e-12. Should be kept way less than 1 + Default=1e-12. Should be kept way less than 1 pad : bool, optional Add zero rows (at the bottom) and/or columns (to the right-hand side) of matrices @@ -178,7 +178,7 @@ def psdp_projgrad( i = 1 err = np.zeros((options["max_iter"] + 1, 1)) # S is the right transformation in our problem statement - s = _init_procustes_projgrad(a, b) + s = _init_procrustes_projgrad(a, b) # F is the function whose norm we want to minimize, F = S@A - B f = s @ a - b # eps = ||S_i - S_{i - 1}||_F @@ -257,37 +257,31 @@ def psdp_opt( This is relabelled to variable f representing the matrix :math:`\mathbf{F}` as in the paper. - options : Dict, optional + options_dict : Dict, optional Dictionary with fields that serve as parameters for the algorithm. max_iter : int - Maximum number of iterations. - Default value is 10000. + Maximum number of iterations. Default=10000. x_tol : float - Stop control for ||X_k - X_{k-1}||_F. - Defaut value is 1e-5. + Stop control for ||X_k - X_{k-1}||_F. Defaut=1e-5. f_tol : float Stop control for |F_k - F_{k-1}|/(1+|F_{k-1}|). - Default value is 1e-12. + Default=1e-12. proj : bool If proj is True we perform Cholesky decomposition else we do spectral - decomposition. - Default value is True. + decomposition. Default=True. gamma : float - Parameter of the non-monotone technique proposed by Zhang-Hager. - Default value is 0.85. + Parameter of the non-monotone technique proposed by Zhang-Hager. Default=0.85. rho : float - Parameter for control the linear approximation in line search. - Default value is 1e-4. + Parameter for control the linear approximation in line search. Default=1e-4. eta : float - Factor for decreasing the step size in the backtracking line search. - Default value is 0.1. + Factor for decreasing the step size in the backtracking line search. Default=0.1. tau : float Initial step size with default value 1e-3. @@ -980,8 +974,7 @@ def _psd_proj(arr: np.ndarray, do_cholesky: bool = True) -> np.ndarray: The input matrix. do_cholesky : bool - Parameter to decide whether or not to perform - Cholesky decomposition. + Parameter to decide whether to perform Cholesky decomposition. Returns ------- @@ -1000,7 +993,7 @@ def _psd_proj(arr: np.ndarray, do_cholesky: bool = True) -> np.ndarray: return _make_positive(arr) -def _init_procustes_projgrad( +def _init_procrustes_projgrad( a: np.ndarray, b: np.ndarray, choice: int = 0 diff --git a/requirements.txt b/requirements.txt index a235283a..c3adc8cd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -numpy>=1.19.5 +numpy>=1.21.5 scipy>=1.5.0 pytest>=5.4.3 sphinx>=2.3.0