From a84f9c14579e11434dad1555c99d80e54d563135 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Mar 2022 07:07:52 -0400 Subject: [PATCH 1/4] Update sphinx requirement from <4.5,>=3.0 to >=3.0,<4.6 (#688) --- docs/sphinx-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx-requirements.txt b/docs/sphinx-requirements.txt index 08c37058aa..57865baf74 100644 --- a/docs/sphinx-requirements.txt +++ b/docs/sphinx-requirements.txt @@ -1,5 +1,5 @@ # Sphinx builds the documentation -sphinx>=3.0,<4.5 +sphinx>=3.0,<4.6 # Sphinx dependencies Pygments>=2.6.1 From 672d19baabe67c56b6d88b64d6f310679a5f881a Mon Sep 17 00:00:00 2001 From: PrSh27 <102277860+PrSh27@users.noreply.github.com> Date: Mon, 28 Mar 2022 20:17:59 +0530 Subject: [PATCH 2/4] Resolve pylint line-too-long for linops (#682) * Remove line-to-long for _problems * Remove * Remove line-too-long for _scaling * - * Remove line-too-long from /linops and add to/problems * Update _kronecker.py * Fix trailing-whitespace * Fix trailing whitespace for kroneker * Fix trailing-whitespaces for _linear_operator --- src/probnum/linops/_kronecker.py | 5 ++++- src/probnum/linops/_linear_operator.py | 12 +++++++----- src/probnum/linops/_scaling.py | 3 ++- tox.ini | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/probnum/linops/_kronecker.py b/src/probnum/linops/_kronecker.py index adf1e0df26..7df3103212 100644 --- a/src/probnum/linops/_kronecker.py +++ b/src/probnum/linops/_kronecker.py @@ -13,7 +13,10 @@ class Symmetrize(_linear_operator.LinearOperator): r"""Symmetrizes a vector in its matrix representation. - Given a vector :math:`x=\operatorname{vec}(X)` representing a square matrix :math:`X`, this linear operator computes :math:`y=\operatorname{vec}(\frac{1}{2}(X + X^\top))`. + Given a vector :math:`x=\operatorname{vec}(X)` + representing a square matrix :math:`X`, + this linear operator computes :math: + `y=\operatorname{vec}(\frac{1}{2}(X + X^\top))`. Parameters ---------- diff --git a/src/probnum/linops/_linear_operator.py b/src/probnum/linops/_linear_operator.py index ce9db727d2..e8d272dd91 100644 --- a/src/probnum/linops/_linear_operator.py +++ b/src/probnum/linops/_linear_operator.py @@ -32,8 +32,8 @@ class LinearOperator: :class:`LinearOperator`, that defers linear operations to the original operators and combines the results. - To construct a concrete :class:`LinearOperator`, either pass appropriate callables to - the constructor of this class, or subclass it. + To construct a concrete :class:`LinearOperator`, either pass appropriate callables + to the constructor of this class, or subclass it. A subclass must implement either one of the methods ``_matvec`` and ``_matmat``, and the attributes/properties ``shape`` (pair of integers) and ``dtype`` (may be @@ -254,7 +254,8 @@ def astype( casting: Controls what kind of data casting may occur. subok: - If True, then sub-classes will be passed-through (default). False is currently not supported for linear operators. + If True, then sub-classes will be passed-through (default). + False is currently not supported for linear operators. copy: Whether to return a new linear operator, even if ``dtype`` is the same. """ @@ -828,8 +829,9 @@ def __matmul__( Returns ------- y : - A `np.matrix` or `np.ndarray` or `RandomVariable` with shape `(M,)` or `(M, 1)`, - depending on the type and shape of the x argument. + A `np.matrix` or `np.ndarray` or `RandomVariable` with + shape `(M,)` or `(M, 1)`,depending on the type and + shape of the x argument. Notes ----- This matvec wraps the user-specified matvec routine or overridden diff --git a/src/probnum/linops/_scaling.py b/src/probnum/linops/_scaling.py index a99e27f8a3..ab80036b66 100644 --- a/src/probnum/linops/_scaling.py +++ b/src/probnum/linops/_scaling.py @@ -16,7 +16,8 @@ class Scaling(_linear_operator.LinearOperator): r"""Scaling linear operator. - Creates a diagonal linear operator which (non-uniformly) scales elements of vectors, defined by + Creates a diagonal linear operator which (non-uniformly) + scales elements of vectors, defined by .. math:: v \mapsto \begin{bmatrix} diff --git a/tox.ini b/tox.ini index 5373b15525..54cc6b24a0 100644 --- a/tox.ini +++ b/tox.ini @@ -69,7 +69,7 @@ commands = pylint src/probnum/diffeq --disable="redefined-outer-name,too-many-instance-attributes,too-many-arguments,too-many-locals,too-few-public-methods,protected-access,unnecessary-pass,unused-variable,unused-argument,no-else-return,no-else-raise,no-self-use,duplicate-code,line-too-long,missing-function-docstring,missing-param-doc,missing-type-doc,missing-raises-doc,missing-return-type-doc" --jobs=0 pylint src/probnum/filtsmooth --disable="no-member,arguments-differ,too-many-arguments,too-many-locals,too-few-public-methods,protected-access,unused-variable,unused-argument,no-self-use,duplicate-code,useless-param-doc" --jobs=0 pylint src/probnum/linalg --disable="no-member,abstract-method,arguments-differ,redefined-builtin,too-many-instance-attributes,too-many-arguments,too-many-locals,too-many-lines,too-many-statements,too-many-branches,too-complex,too-few-public-methods,protected-access,unused-argument,attribute-defined-outside-init,no-else-return,no-else-raise,no-self-use,else-if-used,duplicate-code,line-too-long,missing-module-docstring,missing-param-doc,missing-type-doc,missing-raises-doc,missing-return-type-doc" --jobs=0 - pylint src/probnum/linops --disable="too-many-instance-attributes,too-many-arguments,too-many-locals,protected-access,no-else-return,no-else-raise,else-if-used,line-too-long,missing-class-docstring,missing-function-docstring,missing-raises-doc,duplicate-code" --jobs=0 + pylint src/probnum/linops --disable="too-many-instance-attributes,too-many-arguments,too-many-locals,protected-access,no-else-return,no-else-raise,else-if-used,missing-class-docstring,missing-function-docstring,missing-raises-doc,duplicate-code" --jobs=0 pylint src/probnum/problems --disable="too-many-arguments,too-many-locals,unused-variable,unused-argument,else-if-used,consider-using-from-import,duplicate-code,line-too-long,missing-module-docstring,missing-function-docstring,missing-param-doc,missing-type-doc,missing-raises-doc" --jobs=0 pylint src/probnum/quad --disable="too-many-arguments,missing-module-docstring" --jobs=0 pylint src/probnum/randprocs --disable="arguments-differ,arguments-renamed,too-many-instance-attributes,too-many-arguments,too-many-locals,protected-access,unused-argument,no-else-return,duplicate-code,line-too-long,missing-module-docstring,missing-class-docstring,missing-function-docstring,missing-type-doc,missing-raises-doc,useless-param-doc,useless-type-doc,missing-return-type-doc" --jobs=0 From fc32cceab0c8f304748698697835e87cea422ef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20Pf=C3=B6rtner?= Date: Tue, 29 Mar 2022 10:21:03 +0100 Subject: [PATCH 3/4] Migrate `setup.cfg` to `pyproject.toml` and refactor `pyproject.toml` (#685) * Migrate `setup.cfg` to PEP 621 Project Metadata in `pyproject.toml` * Add URLs in `pyproject.toml` testing config * Update `black` configuration * Update `isort` configuration * Add headers for formatting and linting configuration * Move formatting configuration section * Rearrange linting configuration * Add maintainers and authors * Bugfix in `tool.setuptools.platforms` * Bugfix in package collection * Bugfix in `project.optional-dependencies` * Don't need requirements.txt anymore * One line per package dependency * Bugfix in `[project.version]` * Remove authors and maintainers * Bugfix: `optional-dependencies` is generated dynamically * Fix warning in build process: Add `homepage` URL * Update sphinx requirement from <4.5,>=3.0 to >=3.0,<4.6 (#688) * Resolve pylint line-too-long for linops (#682) * Remove line-to-long for _problems * Remove * Remove line-too-long for _scaling * - * Remove line-too-long from /linops and add to/problems * Update _kronecker.py * Fix trailing-whitespace * Fix trailing whitespace for kroneker * Fix trailing-whitespaces for _linear_operator Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: PrSh27 <102277860+PrSh27@users.noreply.github.com> --- pyproject.toml | 159 ++++++++++++++++++++++++++++++++++------------- requirements.txt | 16 ----- setup.cfg | 102 ------------------------------ setup.py | 25 +++++++- 4 files changed, 141 insertions(+), 161 deletions(-) delete mode 100644 requirements.txt delete mode 100644 setup.cfg diff --git a/pyproject.toml b/pyproject.toml index 90cf323894..bc9fca3414 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,14 +1,82 @@ -# For more information about this pyproject.toml file, see -# PEP 518: https://www.python.org/dev/peps/pep-0518/ +################################################################################ +# PEP 621 Project Metadata # +################################################################################ + +# see https://peps.python.org/pep-0621/ + +[project] +name = "probnum" +description = "Probabilistic Numerics in Python." +readme = "README.md" +requires-python = ">=3.8,<3.11" +license = {file = "LICENSE.txt"} +keywords = [ + "probabilistic-numerics", + "machine-learning", + "numerical-methods", +] +classifiers = [ + "Development Status :: 4 - Beta", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", +] +dependencies = [ + "numpy>=1.20", "numpy>=1.21.3; python_version>='3.10'", + "scipy>=1.4", "scipy>=1.8.0; python_version>='3.10'", +] +dynamic = [ + "version", + "optional-dependencies", +] + +# TODO (pypa/setuptools#3221): Optional dependencies that reference one another +# don't seem to be supported yet. Migrate the optional dependencies in `setup.py` +# here, once this is supported. +# [project.optional-dependencies] +# ... +# full = [ +# "%(jax)s", +# "%(zoo)s", +# "%(pls_calib)s", +# ] + +[project.urls] +homepage = "https://probnum.readthedocs.io/en/stable/" +github = "https://github.com/probabilistic-numerics/probnum" +documentation = "https://probnum.readthedocs.io/en/stable/" +benchmarks = "https://probabilistic-numerics.github.io/probnum-benchmarks/benchmarks/" + +################################################################################ +# PEP 518 Build System Configuration # +################################################################################ + +# see https://peps.python.org/pep-0518/ [build-system] requires = [ - "setuptools>=42", + "setuptools>=61", "wheel", "setuptools_scm[toml]>=6.0", ] build-backend = "setuptools.build_meta" +# see https://setuptools.pypa.io/en/stable/userguide/pyproject_config.html#setuptools-specific-configuration + +[tool.setuptools] +platforms = [ + "any", +] +zip-safe = false +packages = ["probnum"] +package-dir = { "" = "src" } +include-package-data = true + +[tool.setuptools.dynamic] +version = { attr = "probnum._version.version" } + [tool.setuptools_scm] local_scheme = "dirty-tag" write_to = "src/probnum/_version.py" @@ -20,7 +88,13 @@ write_to_template = """ version = \"{version}\" """ -# PyTest configuration +################################################################################ +# Testing Configuration # +################################################################################ + +# see https://docs.pytest.org/en/stable/reference/customize.html +# see https://docs.pytest.org/en/stable/reference/reference.html#ini-options-ref + [tool.pytest.ini_options] addopts = [ "--verbose", @@ -44,28 +118,22 @@ filterwarnings = [ "ignore:the imp module is deprecated in favour of importlib.*:DeprecationWarning:flatbuffers.*" ] +################################################################################ +# Linting Configuration # +################################################################################ -# Configuration of the black code style checker -# For more information about Black's usage of this file, see -# https://github.com/psf/black#pyprojecttoml -[tool.black] -include = '\.pyi?$' -exclude = ''' -/( - \.eggs - | \.git - | \.hg - | \.mypy_cache - | \.tox - | \.venv - | _build - | buck-out - | build - | dist -)/ -''' +[tool.pylint.master] +extension-pkg-whitelist = [ + "numpy", +] +load-plugins = [ + "pylint.extensions.check_elif", + "pylint.extensions.docparams", + "pylint.extensions.docstyle", + "pylint.extensions.overlapping_exceptions", + "pylint.extensions.mccabe", +] -# Pylint configuration [tool.pylint.messages_control] disable = [ # Exceptions suggested by Black: @@ -84,18 +152,6 @@ disable = [ [tool.pylint.format] max-line-length = "88" -[tool.pylint.master] -extension-pkg-whitelist = [ - "numpy", -] -load-plugins = [ - "pylint.extensions.check_elif", - "pylint.extensions.docparams", - "pylint.extensions.docstyle", - "pylint.extensions.overlapping_exceptions", - "pylint.extensions.mccabe", -] - [tool.pylint.design] max-args = 10 max-complexity = 14 @@ -104,12 +160,31 @@ max-locals = 20 [tool.pylint.similarities] ignore-imports = "yes" -# isort configuration +################################################################################ +# Formatting Configuration # +################################################################################ + +# see https://black.readthedocs.io/en/stable/usage_and_configuration/index.html + +[tool.black] +include = '\.pyi?$' +# If `exclude` is not set, `black` excludes all files listed in `.gitignore`. +# The following option extends this list of ignored files. +# see https://black.readthedocs.io/en/stable/usage_and_configuration/file_collection_and_discovery.html#gitignore +extend-exclude = ''' +# A regex preceded with ^/ will apply only to files and directories in the root +# of the project. +/( + \.git + | \.hg +)/ +''' + +# see https://pycqa.github.io/isort/docs/configuration/config_files.html +# see https://pycqa.github.io/isort/docs/configuration/options.html + [tool.isort] -multi_line_output = 3 -include_trailing_comma = true -force_grid_wrap = 0 -use_parentheses = true -line_length = 88 +# see https://pycqa.github.io/isort/docs/configuration/profiles.html#black +profile = "black" combine_as_imports = true force_sort_within_sections = true diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 8fcf3e78c7..0000000000 --- a/requirements.txt +++ /dev/null @@ -1,16 +0,0 @@ -# ============================================================================= -# DEPRECATION WARNING: -# -# This file exists purely for convenience so that requirements can be easily -# installed with -# -# pip install -r requirements.txt -# -# and so that they show up on GitHub. Requirements of the package are -# specified in setup.cfg. Currently parsing of requirements.txt files is not -# supported by setup.cfg. -# -# If you make changes here, make sure to edit setup.cfg as well! -# ============================================================================= -numpy>=1.20 -scipy>=1.4 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 22a92cf53d..0000000000 --- a/setup.cfg +++ /dev/null @@ -1,102 +0,0 @@ -# This file is used to configure your project. -# Read more about the various options under: -# http://setuptools.readthedocs.io/en/latest/setuptools.html#configuring-setup-using-setup-cfg-files - -[metadata] -name = probnum -description = Probabilistic Numerics in Python. -url = https://github.com/probabilistic-numerics/probnum -author = ProbNum Authors -author_email = -license = MIT -long_description = file: README.md -long_description_content_type = text/markdown -keywords = probabilistic-numerics, machine-learning, numerical-methods -# Change if running only on Windows, Mac or Linux (comma-separated) -platforms = any -# Add here all kinds of additional classifiers as defined under -# https://pypi.python.org/pypi?%3Aaction=list_classifiers -classifiers = - Development Status :: 4 - Beta - License :: OSI Approved :: MIT License - Operating System :: OS Independent - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - -[options] -zip_safe = False -packages = find: -include_package_data = True -setup_requires = - setuptools_scm -package_dir = - =src -# Dependencies of the project (semicolon/line-separated): -install_requires = - numpy>=1.20 - numpy>=1.21.3; python_version>="3.10" - scipy>=1.4 - scipy>=1.8.0; python_version>="3.10" -# The usage of test_requires is discouraged, see `Dependency Management` docs -# tests_require = pytest; pytest-cov -# Require a specific Python version, e.g. Python 2.7 or >= 3.6 -python_requires = >=3.8,<3.11 - -[options.packages.find] -where = src -exclude = - tests - -[options.extras_require] -# Add here additional requirements for extra features, to install with: -# `pip install probnum[PDF]` like: -# PDF = ReportLab; RXP - -# Autodiff backends -jax = - jax[cpu]<0.3.5; platform_system!="Windows" - -# Problem zoo dependencies -zoo = - %(jax)s - tqdm>=4.0 - requests>=2.0 - -# Calibration in the probabilistic linear solver -pls_calib = - GPy - # GPy can't be imported without matplotlib. - # This is and should not be a ProbNum dependency. - matplotlib - -# Full installation -full = - %(jax)s - %(zoo)s - %(pls_calib)s - -[options.entry_points] -# Add here console scripts like: -# console_scripts = -# script_name = probnum.module:function -# For example: -# console_scripts = -# fibonacci = probnum.skeleton:run - -[test] -# py.test options when running `python setup.py test` -# addopts = --verbose -extras = True - -[aliases] -dists = bdist_wheel - -[bdist_wheel] -# Use this option if your package is pure-python -universal = 1 - -[build_sphinx] -source_dir = docs -build_dir = build/sphinx -warning-is-error = 1 diff --git a/setup.py b/setup.py index 38ffa75323..3a02420e45 100644 --- a/setup.py +++ b/setup.py @@ -5,5 +5,28 @@ """ from setuptools import setup +# TODO (pypa/setuptools#3221): Migrate this to `[project.optional-dependencies]` in +# `pyproject.toml`, once optional dependencies defined there can reference one another +extras_require = dict() +extras_require["jax"] = [ + "jax[cpu]<0.3.5; platform_system!='Windows'", +] +extras_require["zoo"] = [ + "tqdm>=4.0", + "requests>=2.0", +] + extras_require["jax"] +extras_require["pls_calib"] = [ + "GPy", + # GPy can't be imported without matplotlib. + # This is and should not be a ProbNum dependency. + "matplotlib", +] +extras_require["full"] = ( + extras_require["jax"] + extras_require["zoo"] + extras_require["pls_calib"] +) + + if __name__ == "__main__": - setup() + setup( + extras_require=extras_require, + ) From 0864fcfde37f2f75b46d34933552c1e44b464b80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20Pf=C3=B6rtner?= Date: Tue, 29 Mar 2022 16:00:13 +0100 Subject: [PATCH 4/4] Move contents of `.coveragerc` into `pyproject.toml` (#691) --- .coveragerc | 28 ---------------------------- pyproject.toml | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 28 deletions(-) delete mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index f1f75abbe1..0000000000 --- a/.coveragerc +++ /dev/null @@ -1,28 +0,0 @@ -# .coveragerc to control coverage.py -[run] -branch = True -source = probnum -# omit = bad_file.py - -[paths] -source = - src/ - */site-packages/ - -[report] -# Regexes for lines to exclude from consideration -exclude_lines = - # Have to re-enable the standard pragma - pragma: no cover - - # Don't complain about missing debug-only code: - def __repr__ - if self\.debug - - # Don't complain if tests don't hit defensive assertion code: - raise AssertionError - raise NotImplementedError - - # Don't complain if non-runnable code isn't run: - if 0: - if __name__ == .__main__.: diff --git a/pyproject.toml b/pyproject.toml index bc9fca3414..cc3db6bb2b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -118,6 +118,35 @@ filterwarnings = [ "ignore:the imp module is deprecated in favour of importlib.*:DeprecationWarning:flatbuffers.*" ] +# see https://coverage.readthedocs.io/en/stable/config.html + +[tool.coverage.run] +branch = true +source = [ + "probnum", +] + +[tool.coverage.paths] +source = [ + "src/", + "*/site-packages/", +] + +[tool.coverage.report] +exclude_lines = [ + # Have to re-enable the standard pragma + 'pragma: no cover', + # Don't complain about missing debug-only code: + 'def __repr__(self):', + 'if self\.debug', + # Don't complain if tests don't hit defensive assertion code: + 'raise AssertionError', + 'raise NotImplementedError', + # Don't complain if non-runnable code isn't run: + 'if 0:', + 'if __name__ == .__main__.:', +] + ################################################################################ # Linting Configuration # ################################################################################