Skip to content

Commit

Permalink
Add flake8-docstrings linting rules for documentation using ruff PR #227
Browse files Browse the repository at this point in the history


Introduce flake8-docstrings linting rules and ruff for automatic resolving in the formatting process.
  • Loading branch information
agoscinski authored May 26, 2024
2 parents a5e815e + 972c23d commit 9462c0b
Show file tree
Hide file tree
Showing 49 changed files with 939 additions and 1,471 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ __pycache__
build/
dist/
docs/src/examples
sg_execution_times.rst
7 changes: 6 additions & 1 deletion docs/src/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ Then this package itself
pip install -e .
This install the package in development mode, making it importable globally and allowing
you to edit the code and directly use the updated version.
you to edit the code and directly use the updated version. To see a list of all
supported tox environments please use

.. code-block:: bash
tox -av
Running the tests
-----------------
Expand Down
21 changes: 10 additions & 11 deletions examples/reconstruction/PlotGFRE.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
"""
Global Feature Reconstruction Error (GFRE) and Distortion (GFRD)
================================================================
Example for the usage of the :class:`skmatter.metrics.global_reconstruction_error`
as global feature reconstruction error (GFRE) and
Example for the usage of the :class:`skmatter.metrics.global_reconstruction_error` as
global feature reconstruction error (GFRE) and
:class:`skmatter.metrics.global_reconstruction_distortion` global feature reconstruction
distortion (GFRD). We apply the global reconstruction measures on the degenerate
CH4 manifold dataset. This dataset was specifically constructed to be
representable by a 4-body features (bispectrum) but not by a 3-body features
(power spectrum). In other words the dataset contains environments which are
different, but have the same 3-body features. For more details about the dataset
please refer to `Pozdnyakov 2020 <https://doi.org/10.1103/PhysRevLett.125.166001>`_.
distortion (GFRD). We apply the global reconstruction measures on the degenerate CH4
manifold dataset. This dataset was specifically constructed to be representable by a
4-body features (bispectrum) but not by a 3-body features (power spectrum). In other
words the dataset contains environments which are different, but have the same 3-body
features. For more details about the dataset please refer to `Pozdnyakov 2020
<https://doi.org/10.1103/PhysRevLett.125.166001>`_.
The ``skmatter`` dataset already contains the 3 and 4-body features computed with
`librascal <https://github.com/lab-cosmo/librascal>`_ so we can load it and
compare it with the GFRE/GFRD.
`librascal <https://github.com/lab-cosmo/librascal>`_ so we can load it and compare it
with the GFRE/GFRD.
"""
# %%
#
Expand Down
7 changes: 3 additions & 4 deletions examples/reconstruction/PlotLFRE.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
Pointwise Local Reconstruction Error
====================================
Example for the usage of the
:class:`skmatter.metrics.pointwise_local_reconstruction_error` as pointwise local
reconstruction error (LFRE) on the degenerate CH4 manifold. We apply the local
Expand All @@ -14,9 +13,9 @@
dataset please refer to `Pozdnyakov 2020
<https://doi.org/10.1103/PhysRevLett.125.166001>`_.
The skmatter dataset already contains the 3 and 4-body features computed with
`librascal <https://github.com/lab-cosmo/librascal>`_ so we can load it and compare it
with the LFRE.
The skmatter dataset already contains the 3 and 4-body features computed with `librascal
<https://github.com/lab-cosmo/librascal>`_ so we can load it and compare it with the
LFRE.
"""
# %%
#
Expand Down
3 changes: 1 addition & 2 deletions examples/reconstruction/PlotPointwiseGFRE.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

"""
Pointwise GFRE applied on RKHS features
================================================================
=======================================
Example for the usage of the
:class:`skmatter.metrics.pointwise_global_reconstruction_error` as the pointwise global
feature reconstruction error (pointwise GFRE). We apply the pointwise global feature
Expand Down
1 change: 0 additions & 1 deletion examples/regression/OrthogonalRegressionNonAnalytic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
r"""
Regression with orthogonal projector/matrices
=============================================
In this example, we explain how when using
:class:`skmatter.linear_model.OrthogonalRegression` the option
``use_orthogonal_projector`` can result in non-analytic behavior. In
Expand Down
20 changes: 10 additions & 10 deletions examples/regression/Ridge2FoldCVRegularization.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# %%

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


def micro_bench(ridge):
"""A small benchmark function."""
global N_REPEAT_MICRO_BENCH, X, y
timings = []
train_mse = []
Expand Down Expand Up @@ -177,6 +176,7 @@ def micro_bench(ridge):


def get_train_test_error(estimator):
"""The train tets error based on the estimator."""
global X_train, y_train, X_test, y_test
estimator = estimator.fit(X_train, y_train)
return (
Expand Down
29 changes: 29 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,32 @@ indent = 4
include_trailing_comma = true
lines_after_imports = 2
known_first_party = "skmatter"

[tool.ruff]
exclude = ["docs/src/examples/"]
lint.ignore = [
"F401",
"E203",
"D100",
"D101",
"D102",
"D205",
"D400",
"D401",
]
line-length = 88
lint.select = [
"D",
"E",
"F",
"W",
]

[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.ruff.lint.per-file-ignores]
"examples/**" = [
"D205",
"D400",
]
Loading

0 comments on commit 9462c0b

Please sign in to comment.