Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up psdp docstrings #201

Draft
wants to merge 4 commits into
base: master-backup
Choose a base branch
from
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
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -40,7 +39,7 @@ Dependencies

The following dependencies are required to run Procrustes properly,

* Python >= 3.6: <http://www.python.org/>
* Python >= 3.7: <http://www.python.org/>
* NumPy >= 1.21.5: <http://www.numpy.org/>
* SciPy >= 1.5.0: <http://www.scipy.org/>
* PyTest >= 5.3.4: <https://docs.pytest.org/>
Expand All @@ -55,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.
Expand Down
39 changes: 16 additions & 23 deletions procrustes/psdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>
#
# --
"""Positive semidefinite Procrustes Module."""
"""Positive semi-definite Procrustes Module."""

from math import inf, sqrt
from typing import Dict, Optional
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
-------
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
numpy>=1.19.5
numpy>=1.21.5
scipy>=1.5.0
pytest>=5.4.3
sphinx>=2.3.0