Skip to content

Commit 94981cf

Browse files
authored
Update pre-commits (#54)
* Update pre-commits * Fix mypy error * Update tox, ignore links
1 parent b082cdc commit 94981cf

9 files changed

Lines changed: 16 additions & 27 deletions

File tree

.pre-commit-config.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ default_stages:
77
minimum_pre_commit_version: 2.9.0
88
repos:
99
- repo: https://github.com/pre-commit/mirrors-mypy
10-
rev: v0.991
10+
rev: v1.0.0
1111
hooks:
1212
- id: mypy
1313
additional_dependencies: [numpy==1.20.0, scipy>=1.6.0]
1414
- repo: https://github.com/psf/black
15-
rev: 22.12.0
15+
rev: 23.1.0
1616
hooks:
1717
- id: black
1818
additional_dependencies: [toml]
1919
- repo: https://github.com/timothycrosley/isort
20-
rev: 5.11.4
20+
rev: 5.12.0
2121
hooks:
2222
- id: isort
2323
additional_dependencies: [toml]
@@ -28,7 +28,7 @@ repos:
2828
- id: yesqa
2929
additional_dependencies: [flake8-tidy-imports, flake8-docstrings, flake8-rst-docstrings, flake8-comprehensions, flake8-bugbear, flake8-logging-format, flake8-blind-except, flake8-builtins, flake8-pytest-style, flake8-string-format]
3030
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
31-
rev: v2.5.0
31+
rev: v2.6.0
3232
hooks:
3333
- id: pretty-format-yaml
3434
args: [--autofix, --indent, '4', --preserve-quotes]
@@ -61,7 +61,7 @@ repos:
6161
- id: flake8
6262
additional_dependencies: [flake8-tidy-imports, flake8-docstrings, flake8-rst-docstrings, flake8-comprehensions, flake8-bugbear, flake8-logging-format, flake8-blind-except, flake8-builtins, flake8-pytest-style, flake8-string-format]
6363
- repo: https://github.com/myint/autoflake
64-
rev: v2.0.0
64+
rev: v2.0.1
6565
hooks:
6666
- id: autoflake
6767
args: [--in-place, --remove-all-unused-imports, --remove-unused-variable, --ignore-init-module-imports]
@@ -72,17 +72,17 @@ repos:
7272
name: Check executable files use .sh extension
7373
types: [shell, executable]
7474
- repo: https://github.com/asottile/blacken-docs
75-
rev: v1.12.1
75+
rev: 1.13.0
7676
hooks:
7777
- id: blacken-docs
78-
additional_dependencies: [black==22.10.0]
78+
additional_dependencies: [black==23.1.0]
7979
- repo: https://github.com/asottile/pyupgrade
8080
rev: v3.3.1
8181
hooks:
8282
- id: pyupgrade
8383
args: [--py3-plus, --py37-plus]
8484
- repo: https://github.com/pre-commit/pygrep-hooks
85-
rev: v1.9.0
85+
rev: v1.10.0
8686
hooks:
8787
- id: python-no-eval
8888
- id: python-use-type-annotations

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-r ../requirements.txt
22
nbsphinx>=0.8
3-
sphinx==4.0.2 # https://github.com/spatialaudio/nbsphinx/issues/584
3+
sphinx>=5
44
sphinx-autodoc-annotation
55
sphinx-autodoc-typehints>=1.10.3
66
sphinx-copybutton

docs/source/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import pygpcca # noqa: E402
2121

22-
needs_sphinx = "3.3"
22+
needs_sphinx = "5"
2323
# -- Project information -----------------------------------------------------
2424

2525
project = "pyGPCCA"
@@ -115,6 +115,7 @@
115115

116116
# linkcheck
117117
linkcheck_anchors = False # problem with specifying lines on GitHub in `acknowledgments.rst`
118+
linkcheck_ignore = ["https://doi.org/10.1021/acs.jctc.8b00079", "https://pubs.acs.org/doi/abs/10.1021/acs.jctc.8b00079"]
118119

119120
# Add any paths that contain custom static files (such as style sheets) here,
120121
# relative to this directory. They are copied after the builtin static files,

pygpcca/_gpcca.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ def _objective(alpha: np.ndarray, X: np.ndarray) -> float:
471471

472472
# Compute value of the objective function.
473473
# from Matlab: optval = m - trace( diag(1 ./ A(1,:)) * (A' * A) )
474-
return m - np.trace(np.diag(1.0 / rot_mat[0, :]).dot(rot_mat.conj().T.dot(rot_mat))) # type: ignore[no-any-return]
474+
return m - np.trace(np.diag(1.0 / rot_mat[0, :]).dot(rot_mat.conj().T.dot(rot_mat))) # type: ignore[return-value]
475475

476476

477477
@d.dedent

pygpcca/utils/_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ def stationary_distribution_from_eigenvector(P: np.ndarray) -> np.ndarray:
410410

411411

412412
def _is_stationary_distribution(T: Union[np.ndarray, spmatrix], pi: np.ndarray) -> bool:
413-
414413
# check the shapes
415414
if not T.shape[0] == T.shape[1] or not T.shape[0] == pi.shape[0]:
416415
raise ValueError("Shape mismatch.")

tests/test_gpcca.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,6 @@ def test_P_2_LM(
851851
assert_allclose(g.dominant_eigenvalues, top_eigenvalues_P_2_LM[:n_m])
852852

853853
def test_split_warning_LM(self, P_2: np.ndarray):
854-
855854
g = GPCCA(P_2, eta=None, z="LM")
856855

857856
with pytest.warns(
@@ -880,7 +879,6 @@ def test_split_warning_LM(self, P_2: np.ndarray):
880879
g.optimize({"m_min": 11, "m_max": 12})
881880

882881
def test_split_raise_LM(self, P_2: np.ndarray):
883-
884882
g = GPCCA(P_2, eta=None, z="LM")
885883

886884
with pytest.raises(
@@ -939,7 +937,6 @@ def test_P_2_LR(
939937
assert_allclose(g.dominant_eigenvalues, top_eigenvalues_P_2_LR[:n_m])
940938

941939
def test_split_warning_LR(self, P_2: np.ndarray):
942-
943940
g = GPCCA(P_2, eta=None, z="LR")
944941

945942
with pytest.warns(
@@ -962,7 +959,6 @@ def test_split_warning_LR(self, P_2: np.ndarray):
962959
g.optimize({"m_min": 10, "m_max": 12})
963960

964961
def test_split_raise_LR(self, P_2: np.ndarray):
965-
966962
g = GPCCA(P_2, eta=None, z="LR")
967963

968964
with pytest.raises(
@@ -985,7 +981,6 @@ def test_split_raise_LR(self, P_2: np.ndarray):
985981
g.optimize(11)
986982

987983
def test_optimize_range_all_invalid(self, P_2: np.ndarray, mocker):
988-
989984
g = GPCCA(P_2, eta=None, z="LR")
990985

991986
mocker.patch(

tests/test_stat_dist.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ def test_stat_dist_check(
9191
test_matrix_2: np.ndarray,
9292
test_matrix_2_stationary_distribution,
9393
):
94-
9594
assert _is_stationary_distribution(test_matrix_1, test_matrix_1_stationary_distribution)
9695
assert _is_stationary_distribution(test_matrix_2, test_matrix_2_stationary_distribution)
9796

tests/test_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def test_eigendecomposition_slepsc_regression(
1717
test_matrix_2_eigenvalues: np.ndarray,
1818
test_matrix_2_eigenvectors: np.ndarray,
1919
):
20-
2120
eigs_1, vecs_1 = _eigs_slepc(csr_matrix(test_matrix_1), k=11)
2221
assert_allclose(
2322
test_matrix_1_eigenvalues,

tox.ini

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,43 +139,39 @@ commands =
139139

140140
[testenv:lint]
141141
description = Perform linting.
142-
basepython = python3.8
143142
deps = pre-commit>=2.7.1
144143
skip_install = true
145144
commands = pre-commit run --all-files --show-diff-on-failure {posargs:}
146145

147146
[testenv:clean-docs]
148147
description = Clean the documentation artifacts.
149-
basepython = python3.8
150148
deps =
151149
skip_install = true
152150
changedir = {toxinidir}/docs
153-
whitelist_externals = make
151+
allowlist_externals = make
154152
commands = make clean
155153

156154
[testenv:check-docs]
157155
description = Check the links in the docs.
158-
basepython = python3.8
159156
deps = -r{toxinidir}/docs/requirements.txt
160157
skip_install = true
161-
whitelist_externals = sphinx-build
158+
allowlist_externals = sphinx-build
159+
pass_env = PYENCHANT_LIBRARY_PATH
162160
commands =
163161
sphinx-build -b spelling {toxinidir}/docs/source {toxinidir}/docs/build/spellcheck
164162
sphinx-build -q -W --keep-going -b linkcheck {toxinidir}/docs/source {toxinidir}/docs/build/linkcheck
165163

166164
[testenv:docs]
167165
description = Build the documentation.
168-
basepython = python3.8
169166
skip_install = true
170167
deps = -r{toxinidir}/docs/requirements.txt
171-
whitelist_externals = sphinx-build
168+
allowlist_externals = sphinx-build
172169
commands =
173170
sphinx-build --color -b html {toxinidir}/docs/source {toxinidir}/docs/build/html
174171
python -c 'import pathlib; print(f"Documentation is available under:", pathlib.Path(f"{toxinidir}") / "docs" / "build" / "html" / "index.html")'
175172

176173
[testenv:readme]
177174
description = Check if README renders on PyPI.
178-
basepython = python3.8
179175
deps = twine >= 1.12.1
180176
skip_install = true
181177
commands =

0 commit comments

Comments
 (0)