From 9ad2d963c4b6bb4338fab9b143a4534cb51a5dd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicholas=20Kr=C3=A4mer?= Date: Wed, 11 Oct 2023 09:05:36 +0200 Subject: [PATCH] Bundled all meta-information in pyproject.toml (#154) * Bundled all meta-information in pyproject.toml * Removed python 3.11 claim --- docs/benchmarks/jacobian_squared.py | 4 +- matfree/backend/typing.py | 3 +- pyproject.toml | 132 +++++++++++++++++++++++++--- setup.cfg | 41 --------- setup.py | 5 -- 5 files changed, 122 insertions(+), 63 deletions(-) delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/docs/benchmarks/jacobian_squared.py b/docs/benchmarks/jacobian_squared.py index bf9ffc9..7ae2223 100644 --- a/docs/benchmarks/jacobian_squared.py +++ b/docs/benchmarks/jacobian_squared.py @@ -73,7 +73,7 @@ def matvec(num, key): @func.partial(benchmark_util.error_and_time, error_fun=error_fun) @func.partial(func.jit, static_argnums=0) def slq_low(num, key): - """SLQ(1)""" # noqa: D400,D415 + """SLQ(1)""" # noqa: D400 return slq.trace_of_matfun_spd( matfun, jvp, @@ -86,7 +86,7 @@ def slq_low(num, key): @func.partial(benchmark_util.error_and_time, error_fun=error_fun) @func.partial(func.jit, static_argnums=0) def slq_high(num, key): - """SLQ(5)""" # noqa: D400,D415 + """SLQ(5)""" # noqa: D400 return slq.trace_of_matfun_spd( matfun, jvp, diff --git a/matfree/backend/typing.py b/matfree/backend/typing.py index d18cd25..9fe5b5b 100644 --- a/matfree/backend/typing.py +++ b/matfree/backend/typing.py @@ -1,8 +1,7 @@ """Types.""" # fmt: off from collections.abc import Callable # noqa: F401 -from typing import (Any, Generic, Iterable, Sequence, # noqa: F401, UP035 - Tuple, TypeVar) +from typing import Any, Generic, Iterable, Sequence, Tuple, TypeVar # noqa: F401 from jax import Array # noqa: F401 diff --git a/pyproject.toml b/pyproject.toml index 5407fc8..19dde3b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,24 +1,114 @@ [build-system] requires = [ - "setuptools>=42", - "wheel", - "setuptools_scm[toml]>=6.0", + "setuptools>=64", + "setuptools_scm>=8", ] build-backend = "setuptools.build_meta" +[project] +name = "matfree" +authors = [ + {name="Nicholas Krämer", email="pekra@dtu.dk"} +] +description = "Matrix-free numerical linear algebra." +readme = "README.md" +requires-python=">=3.8" +classifiers = [ + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", +] +dynamic = ["version"] + + +[project.optional-dependencies] +cpu = [ + "jax[cpu]", +] +test =[ + "pytest", + "pytest-cases", +] +lint =[ + "matfree[test]", + "pre-commit", +] +format =[ + "isort", + "black", +] +doc = [ + "mkdocs", + "mkdocs-material", + "mkdocstrings", + "mkdocstrings-python", + "matplotlib", + "tqdm", +] +full = [ + "matfree[cpu]", + "matfree[test]", + "matfree[lint]", + "matfree[format]", + "matfree[doc]", +] + + + +[tool.setuptools.packages.find] +where = ["."] # list of folders that contain the packages (["."] by default) +include = ["matfree*"] # package names should match these glob patterns (["*"] by default) + + [tool.setuptools_scm] -local_scheme = "dirty-tag" -write_to = "matfree/_version.py" -write_to_template = """ -# pylint: skip-file -# coding: utf-8 -# file generated by setuptools_scm -# don't change, don't track in version control -version = \"{version}\" -""" +version_file = "matfree/_version.py" + +[project.urls] +"Documentation" = "https://pnkraemer.github.io/matfree/" +"Issue tracker" = "https://github.com/pnkraemer/matfree/issues" + + [tool.ruff] +include = ["*.py", "**/pyproject.toml", "*.ipynb"] # See: https://beta.ruff.rs/docs/rules/ -select = ["E", "F", "D", "UP", "B", "A", "ICN", "PT", "Q", "RET", "SIM", "ARG", "RUF"] +select = [ + # pycodestyle (warning, error) + "W", + "E", + # Pyflakes: + "F", + # pydocstyle: + "D", + # pyupgrade: + "UP", + # flake8-bugbear: + "B", + # flake8-builtins: + "A", + # flake8-import-conventions: + "ICN", + # flake8-pytest-style: + "PT", + # flake8-quotes: + "Q", + # flake8-return: + "RET", + # flake8-simplify: + "SIM", + # flake8-unused-arguments: + "ARG", + # Ruff-specific rules: + "RUF", + # isort: + "I", + # flake8-errormsg: + "EM", + # tryceratops: + "TRY", +] ignore = [ # warning: `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible. "D203", @@ -26,6 +116,8 @@ ignore = [ "D213", # zip(..., strict=True/False) is not supported on Python < 3.10 "B905", + # Magic methods don't need a docstring: + "D105", ] [tool.ruff.per-file-ignores] @@ -39,3 +131,17 @@ ignore = [ "matfree/backend/progressbar.py" = ["D103"] "matfree/backend/testing.py" = ["D103"] "matfree/backend/time.py" = ["D103"] + +[tool.ruff.pydocstyle] +convention = "numpy" + + +[tool.isort] +multi_line_output = "3" +include_trailing_comma = "true" +force_grid_wrap = "0" +use_parentheses = "true" +line_length = "88" + +[tool.black] +line-length = "88" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 9a0b2d8..0000000 --- a/setup.cfg +++ /dev/null @@ -1,41 +0,0 @@ -[metadata] -name = matfree -description = Matrix-free numerical linear algebra including trace-estimation. -author = Nicholas Krämer -author_email = pekra@dtu.dk -license = MIT -license_file = LICENSE -long_description = file: README.md -long_description_content_type = text/markdown - -[options] -packages = find: -python_requires = >=3.8 - - -[options.extras_require] -cpu = - jax[cpu] -test = - pytest - pytest-cases -lint = - %(test)s - pre-commit -format = - isort - black -doc = - mkdocs - mkdocs-material - mkdocstrings - mkdocstrings-python - # Benchmarks - matplotlib - tqdm -full = - %(cpu)s - %(lint)s - %(test)s - %(doc)s - %(format)s diff --git a/setup.py b/setup.py deleted file mode 100644 index 8f796bb..0000000 --- a/setup.py +++ /dev/null @@ -1,5 +0,0 @@ -"""Setup. Required for the installation in editable mode.""" - -from setuptools import setup - -setup()