diff --git a/.cspell.json b/.cspell.json index 85b8ff4f..65bd1553 100644 --- a/.cspell.json +++ b/.cspell.json @@ -28,6 +28,7 @@ ".pre-commit-config.yaml", ".prettierignore", ".readthedocs.yml", + ".taplo.toml", ".vscode/*", "CITATION.cff", "codecov.yml", diff --git a/.taplo.toml b/.taplo.toml index 0db1df7c..71fcb1be 100644 --- a/.taplo.toml +++ b/.taplo.toml @@ -10,3 +10,10 @@ compact_inline_tables = true indent_string = " " reorder_arrays = true reorder_keys = true + +[[rule]] +include = ["**/pyproject.toml"] +keys = ["tool.tox"] + +[rule.formatting] +reorder_arrays = false diff --git a/pyproject.toml b/pyproject.toml index 6b4b38d9..9b2dd4d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -438,151 +438,165 @@ sort_first = [ "project", "tool.setuptools", "tool.setuptools_scm", + "tool.tox.env_run_base", ] spaces_indent_inline_array = 4 trailing_comma_inline_array = true [tool.tox] -legacy_tox_ini = """ -[tox] -envlist = - cov, - docnb-force, - linkcheck, - sty, -skip_install = True -skip_missing_interpreters = True -skipsdist = True - -[testenv] -allowlist_externals = - pytest -commands = - pytest {posargs} -description = Run all unit tests -passenv = * -setenv = - PYTHONHASHSEED = 0 - -[testenv:bench] -allowlist_externals = - pytest -commands = - pytest {posargs:benchmarks} \ - --durations=0 \ - --benchmark-autosave \ - -k=benchmark -description = Run benchmark tests and visualize in histogram - -[testenv:cov] -allowlist_externals = - pytest -commands = - pytest {posargs:src tests} \ - --cov-fail-under=85 \ - --cov-report=html \ - --cov-report=xml \ - --cov=tensorwaves -description = Compute test coverage - -[testenv:jax] -allowlist_externals = - pytest -commands = - pytest {posargs:} \ - -k="benchmark or not benchmark" \ - -k="not (ampform or four_momenta or numba or tensorflow or tf)" \ - --benchmark-disable -description = Run tests with JAX only - -[testenv:doc] -allowlist_externals = - sphinx-build -commands = - sphinx-build \ - --builder=dirhtml \ - --fail-on-warning \ - --keep-going \ - --show-traceback \ - docs/ docs/_build/html -description = Build documentation and API through Sphinx -setenv = - {[testenv]setenv} - PYTHONWARNINGS = - -[testenv:docnb] -base = doc -description = {[testenv:doc]description} with cached notebook execution -setenv = - {[testenv:doc]setenv} - EXECUTE_NB = yes - -[testenv:docnb-force] -base = doc -description = {[testenv:doc]description} with notebook execution (no cache) -setenv = - {[testenv:doc]setenv} - FORCE_EXECUTE_NB = yes - -[testenv:doclive] -allowlist_externals = - sphinx-autobuild -base = doc -commands = - sphinx-autobuild \ - --builder=dirhtml \ - --ignore=docs/_build/ \ - --ignore=docs/api/ \ - --ignore=docs/usage/logs/ \ - --open-browser \ - --port=0 \ - --re-ignore='.*/__pycache__/.*' \ - --re-ignore='.*/.ipynb_checkpoints/.*' \ - --re-ignore='.*/.virtual_documents/.*' \ - --re-ignore='.*\\.csv' \ - --re-ignore='.*\\.gif' \ - --re-ignore='.*\\.gv' \ - --re-ignore='.*\\.inv' \ - --re-ignore='.*\\.json' \ - --re-ignore='.*\\.pickle' \ - --re-ignore='.*\\.png' \ - --re-ignore='.*\\.svg' \ - --re-ignore='.*\\.ya?ml' \ - --re-ignore='docs/usage/sub_expr_f?' \ - --watch=docs \ - --watch=src \ - docs/ docs/_build/html -description = Set up a server to directly preview changes to the HTML pages - -[testenv:docnblive] -base = doclive -description = {[testenv:doclive]description} with notebook execution (no cache) -setenv = - {[testenv:doclive]setenv} - EXECUTE_NB = yes - -[testenv:linkcheck] -allowlist_externals = - sphinx-build -base = doc -commands = - sphinx-build \ - --builder=linkcheck \ - --show-traceback \ - docs/ docs/_build/linkcheck -description = Check external links in the documentation (requires internet connection) - -[testenv:nb] -allowlist_externals = - pytest -commands = - pytest --nbmake {posargs:docs} -description = Run all notebooks with pytest - -[testenv:sty] -allowlist_externals = - pre-commit -commands = - pre-commit run --all-files {posargs} -description = Perform all linting, formatting, and spelling checks -""" +env_list = [ + "cov", + "docnb-force", + "linkcheck", + "sty", +] +no_package = true +requires = ["tox>=4.21.0"] +skip_install = true +skip_missing_interpreters = true + +[tool.tox.env_run_base] +allowlist_externals = ["pytest"] +commands = [["pytest", {replace = "posargs", extend = true}]] +description = "Run all unit tests" +pass_env = ["*"] +set_env.PYTHONHASHSEED = "0" + +[tool.tox.env.bench] +allowlist_externals = ["pytest"] +commands = [ + [ + "pytest", + "{posargs:benchmarks}", + "--durations=0", + "--benchmark-autosave", + "-k=benchmark", + ], +] +description = "Run benchmark tests and visualize in histogram" + +[tool.tox.env.cov] +allowlist_externals = ["pytest"] +commands = [ + [ + "pytest", + {replace = "posargs", default = ["src", "tests"], extend = true}, + "--cov-fail-under=85", + "--cov-report=html", + "--cov-report=xml", + "--cov=tensorwaves", + ], +] +description = "Compute test coverage" + +[tool.tox.env.doc] +allowlist_externals = ["sphinx-build"] +commands = [ + [ + "sphinx-build", + "--builder=dirhtml", + "--fail-on-warning", + "--keep-going", + "--show-traceback", + "docs/", + "docs/_build/html", + ], +] +description = "Build documentation and API through Sphinx" +set_env.PYTHONWARNINGS = "" + +[tool.tox.env.doclive] +allowlist_externals = ["sphinx-autobuild"] +base = ["tool.tox.env.doc", "tool.tox.env_run_base"] +commands = [ + [ + "sphinx-autobuild", + "--builder=dirhtml", + "--ignore=docs/_build/", + "--ignore=docs/api/", + "--ignore=docs/usage/logs/", + "--open-browser", + "--port=0", + "--re-ignore='.*/__pycache__/.*'", + "--re-ignore='.*/.ipynb_checkpoints/.*'", + "--re-ignore='.*/.virtual_documents/.*'", + "--re-ignore='.*\\.csv'", + "--re-ignore='.*\\.gif'", + "--re-ignore='.*\\.gv'", + "--re-ignore='.*\\.inv'", + "--re-ignore='.*\\.json'", + "--re-ignore='.*\\.pickle'", + "--re-ignore='.*\\.png'", + "--re-ignore='.*\\.svg'", + "--re-ignore='.*\\.ya?ml'", + "--re-ignore='docs/usage/sub_expr_f?'", + "--watch=docs", + "--watch=src", + "docs/", + "docs/_build/html", + ], +] +description = "Set up a server to directly preview changes to the HTML pages" + +[tool.tox.env.docnb] +base = ["tool.tox.env.doc", "tool.tox.env_run_base"] +description = "{[tool.tox.env.doc]description} with cached notebook execution" +set_env = [ + {replace = "ref", of = ["tool.tox.env.doc.set_env"]}, + {EXECUTE_NB = "yes"}, +] + +[tool.tox.env.docnb-force] +base = ["tool.tox.env.doc", "tool.tox.env_run_base"] +description = "{[tool.tox.env.doc]description} with notebook execution (no cache)" +set_env = [ + {replace = "ref", of = ["tool.tox.env.doc.set_env"]}, + {FORCE_EXECUTE_NB = "yes"}, +] + +[tool.tox.env.docnblive] +base = ["tool.tox.env.doclive", "tool.tox.env_run_base"] +description = "{[tool.tox.env.doclive]description} with notebook execution (no cache)" +set_env = [ + {replace = "ref", of = ["tool.tox.env.doclive.set_env"]}, + {EXECUTE_NB = "yes"}, +] + +[tool.tox.env.jax] +allowlist_externals = ["pytest"] +commands = [ + [ + "pytest", + {replace = "posargs", extend = true}, + "-k", + "benchmark or not benchmark", + "-k", + "not (ampform or four_momenta or numba or tensorflow or tf)", + "--benchmark-disable", + ], +] +description = "Run tests with JAX only" + +[tool.tox.env.linkcheck] +allowlist_externals = ["sphinx-build"] +base = ["tool.tox.env.doc", "tool.tox.env_run_base"] +commands = [ + [ + "sphinx-build", + "--builder=linkcheck", + "--show-traceback", + "docs/", + "docs/_build/linkcheck", + ], +] +description = "Check external links in the documentation (requires internet connection)" + +[tool.tox.env.nb] +allowlist_externals = ["pytest"] +commands = [["pytest", "--nbmake", "{posargs:docs}"]] +description = "Run all notebooks with pytest" + +[tool.tox.env.sty] +allowlist_externals = ["pre-commit"] +commands = [["pre-commit", "run", "--all-files", {replace = "posargs", extend = true}]] +description = "Perform all linting, formatting, and spelling checks"