Skip to content

Commit 9462c0b

Browse files
authored
Add flake8-docstrings linting rules for documentation using ruff PR #227
Introduce flake8-docstrings linting rules and ruff for automatic resolving in the formatting process.
2 parents a5e815e + 972c23d commit 9462c0b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+939
-1471
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ __pycache__
1010
build/
1111
dist/
1212
docs/src/examples
13+
sg_execution_times.rst

docs/src/contributing.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ Then this package itself
2626
pip install -e .
2727
2828
This install the package in development mode, making it importable globally and allowing
29-
you to edit the code and directly use the updated version.
29+
you to edit the code and directly use the updated version. To see a list of all
30+
supported tox environments please use
31+
32+
.. code-block:: bash
33+
34+
tox -av
3035
3136
Running the tests
3237
-----------------

examples/reconstruction/PlotGFRE.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,19 @@
44
"""
55
Global Feature Reconstruction Error (GFRE) and Distortion (GFRD)
66
================================================================
7-
8-
Example for the usage of the :class:`skmatter.metrics.global_reconstruction_error`
9-
as global feature reconstruction error (GFRE) and
7+
Example for the usage of the :class:`skmatter.metrics.global_reconstruction_error` as
8+
global feature reconstruction error (GFRE) and
109
:class:`skmatter.metrics.global_reconstruction_distortion` global feature reconstruction
11-
distortion (GFRD). We apply the global reconstruction measures on the degenerate
12-
CH4 manifold dataset. This dataset was specifically constructed to be
13-
representable by a 4-body features (bispectrum) but not by a 3-body features
14-
(power spectrum). In other words the dataset contains environments which are
15-
different, but have the same 3-body features. For more details about the dataset
16-
please refer to `Pozdnyakov 2020 <https://doi.org/10.1103/PhysRevLett.125.166001>`_.
10+
distortion (GFRD). We apply the global reconstruction measures on the degenerate CH4
11+
manifold dataset. This dataset was specifically constructed to be representable by a
12+
4-body features (bispectrum) but not by a 3-body features (power spectrum). In other
13+
words the dataset contains environments which are different, but have the same 3-body
14+
features. For more details about the dataset please refer to `Pozdnyakov 2020
15+
<https://doi.org/10.1103/PhysRevLett.125.166001>`_.
1716
1817
The ``skmatter`` dataset already contains the 3 and 4-body features computed with
19-
`librascal <https://github.com/lab-cosmo/librascal>`_ so we can load it and
20-
compare it with the GFRE/GFRD.
18+
`librascal <https://github.com/lab-cosmo/librascal>`_ so we can load it and compare it
19+
with the GFRE/GFRD.
2120
"""
2221
# %%
2322
#

examples/reconstruction/PlotLFRE.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44
Pointwise Local Reconstruction Error
55
====================================
6-
76
Example for the usage of the
87
:class:`skmatter.metrics.pointwise_local_reconstruction_error` as pointwise local
98
reconstruction error (LFRE) on the degenerate CH4 manifold. We apply the local
@@ -14,9 +13,9 @@
1413
dataset please refer to `Pozdnyakov 2020
1514
<https://doi.org/10.1103/PhysRevLett.125.166001>`_.
1615
17-
The skmatter dataset already contains the 3 and 4-body features computed with
18-
`librascal <https://github.com/lab-cosmo/librascal>`_ so we can load it and compare it
19-
with the LFRE.
16+
The skmatter dataset already contains the 3 and 4-body features computed with `librascal
17+
<https://github.com/lab-cosmo/librascal>`_ so we can load it and compare it with the
18+
LFRE.
2019
"""
2120
# %%
2221
#

examples/reconstruction/PlotPointwiseGFRE.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
"""
55
Pointwise GFRE applied on RKHS features
6-
================================================================
7-
6+
=======================================
87
Example for the usage of the
98
:class:`skmatter.metrics.pointwise_global_reconstruction_error` as the pointwise global
109
feature reconstruction error (pointwise GFRE). We apply the pointwise global feature

examples/regression/OrthogonalRegressionNonAnalytic.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
r"""
44
Regression with orthogonal projector/matrices
55
=============================================
6-
76
In this example, we explain how when using
87
:class:`skmatter.linear_model.OrthogonalRegression` the option
98
``use_orthogonal_projector`` can result in non-analytic behavior. In

examples/regression/Ridge2FoldCVRegularization.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# %%
22

33
r"""
4-
Ridge2FoldCV for data with low effective rank
5-
=======================================================
6-
In this notebook we explain in more detail how
7-
:class:`skmatter.linear_model.Ridge2FoldCV` speeds up the
8-
cross-validation optimizing the regularitzation parameter :param alpha: and
9-
compare it with existing solution for that in scikit-learn
10-
:class:`slearn.linear_model.RidgeCV`.
11-
:class:`skmatter.linear_model.Ridge2FoldCV` was designed to predict
12-
efficiently feature matrices, but it can be also useful for the prediction
13-
single targets.
4+
Ridge2FoldCV for data with low effective rank
5+
=============================================
6+
In this notebook we explain in more detail how
7+
:class:`skmatter.linear_model.Ridge2FoldCV` speeds up the cross-validation optimizing
8+
the regularitzation parameter :param alpha: and compare it with existing solution for
9+
that in scikit-learn :class:`slearn.linear_model.RidgeCV`.
10+
:class:`skmatter.linear_model.Ridge2FoldCV` was designed to predict efficiently feature
11+
matrices, but it can be also useful for the prediction single targets.
1412
"""
1513
# %%
1614
#
@@ -128,6 +126,7 @@
128126

129127

130128
def micro_bench(ridge):
129+
"""A small benchmark function."""
131130
global N_REPEAT_MICRO_BENCH, X, y
132131
timings = []
133132
train_mse = []
@@ -177,6 +176,7 @@ def micro_bench(ridge):
177176

178177

179178
def get_train_test_error(estimator):
179+
"""The train tets error based on the estimator."""
180180
global X_train, y_train, X_test, y_test
181181
estimator = estimator.fit(X_train, y_train)
182182
return (

pyproject.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,32 @@ indent = 4
8686
include_trailing_comma = true
8787
lines_after_imports = 2
8888
known_first_party = "skmatter"
89+
90+
[tool.ruff]
91+
exclude = ["docs/src/examples/"]
92+
lint.ignore = [
93+
"F401",
94+
"E203",
95+
"D100",
96+
"D101",
97+
"D102",
98+
"D205",
99+
"D400",
100+
"D401",
101+
]
102+
line-length = 88
103+
lint.select = [
104+
"D",
105+
"E",
106+
"F",
107+
"W",
108+
]
109+
110+
[tool.ruff.lint.pydocstyle]
111+
convention = "numpy"
112+
113+
[tool.ruff.lint.per-file-ignores]
114+
"examples/**" = [
115+
"D205",
116+
"D400",
117+
]

0 commit comments

Comments
 (0)