Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
name: Performance regression
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-python@v6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/redirect-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
</body>
</html>' > build/index.html
- id: deployment
uses: actions/upload-pages-artifact@v4
uses: actions/upload-pages-artifact@v5
with:
path: build/

Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
- id: check-useless-excludes

- repo: https://github.com/ComPWA/policy
rev: 0.8.10
rev: 0.8.13
hooks:
- id: check-dev-files
args:
Expand Down Expand Up @@ -61,7 +61,7 @@ repos:
metadata.vscode

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.12
rev: v0.15.20
hooks:
- id: ruff-check
args: [--fix]
Expand Down Expand Up @@ -114,7 +114,7 @@ repos:
- --in-place

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.37.2
rev: 0.37.4
hooks:
- id: check-jsonschema
name: Check CITATION.cff
Expand All @@ -127,7 +127,7 @@ repos:
pass_filenames: false

- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v10.0.0
rev: v10.0.1
hooks:
- id: cspell
language_version: 25.9.0
Expand All @@ -154,6 +154,6 @@ repos:
types_or: [python, pyi, jupyter]

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.11.13
rev: 0.11.26
hooks:
- id: uv-lock
5 changes: 4 additions & 1 deletion .taplo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ reorder_keys = true

[[rule]]
include = ["**/pyproject.toml"]
keys = ["tool.poe.tasks"]
keys = [
"tool.poe.groups",
"tool.poe.tasks",
]

[rule.formatting]
reorder_arrays = false
5 changes: 4 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ def get_tensorflow_url() -> str:
create_tensorflow_inventory()
set_intersphinx_version_remapping({
"matplotlib": {"3.5.1": "3.5.0"},
"pandas": {"3.0.2": "3.0.1"},
"pandas": {
"3.0.2": "3.0.1",
"3.0.3": "3.0.1",
},
"scipy": {"1.7.3": "1.7.1"},
})

Expand Down
174 changes: 92 additions & 82 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -182,48 +182,10 @@ isolated = true
no-group = "dev"
type = "uv"

[tool.poe.tasks.all]
help = "Run all continuous integration (CI) tasks locally"
ignore_fail = "return_non_zero"
sequence = [
"benchmark",
"cov",
"docnb-force",
"linkcheck",
"style",
"test-all",
]

[tool.poe.tasks.benchmark]
cmd = """
pytest benchmarks \
--benchmark-autosave \
--benchmark-json benchmarks/output.json \
--durations=0 \
-k benchmark
"""
executor = {extra = ["jax", "numba", "pwa"], group = "test"}
help = "Run benchmark tests and visualize performance"
[tool.poe.groups.doc]
heading = "Documentation"

[tool.poe.tasks.cov]
cmd = """
pytest \
--cov=tensorwaves \
--cov-fail-under=85 \
--cov-report=html \
--cov-report=xml \
${paths}
"""
executor = {extra = ["jax", "numba", "pwa"], group = "test"}
help = "Compute how much of the source code is covered by tests"

[[tool.poe.tasks.cov.args]]
default = ""
multiple = true
name = "paths"
positional = true

[tool.poe.tasks.doc]
[tool.poe.groups.doc.tasks.doc]
cmd = """
sphinx-build \
--builder=html \
Expand All @@ -237,7 +199,7 @@ env = {PYTHONWARNINGS = ""}
executor = {group = "doc"}
help = "Build documentation and API"

[tool.poe.tasks.doclive]
[tool.poe.groups.doc.tasks.doclive]
cmd = """
sphinx-autobuild \
--builder=html \
Expand Down Expand Up @@ -275,45 +237,22 @@ sphinx-autobuild \
executor = {group = "doc", with = "sphinx-autobuild"}
help = "Set up a server to directly preview changes to the HTML pages"

[tool.poe.tasks.docnb]
[tool.poe.groups.doc.tasks.docnb]
env = {EXECUTE_NB = "yes"}
help = "Build documentation and API with cached notebook execution"
sequence = ["doc"]

[tool.poe.tasks.docnb-force]
[tool.poe.groups.doc.tasks.docnb-force]
env = {FORCE_EXECUTE_NB = "yes"}
help = "Build documentation and API with notebook execution (no cache)"
sequence = ["doc"]

[tool.poe.tasks.docnblive]
[tool.poe.groups.doc.tasks.docnblive]
env = {EXECUTE_NB = "yes"}
help = "Set up a server to directly preview changes to the HTML pages with cached notebook execution"
sequence = ["doclive"]

[tool.poe.tasks.jax]
cmd = """
pytest \
-k 'benchmark or not benchmark' \
-k 'not (ampform or four_momenta or numba or tensorflow or tf)' \
--benchmark-disable \
${paths}
"""
executor = {extra = "jax", group = "test"}
help = "Run tests with JAX only"

[[tool.poe.tasks.jax.args]]
default = "src tests"
multiple = true
name = "paths"
positional = true

[tool.poe.tasks.lab]
args = [{name = "paths", default = "", positional = true}]
cmd = "jupyter lab ${paths}"
executor = {group = "jupyter"}
help = "Launch Jupyter Lab"

[tool.poe.tasks.linkcheck]
[tool.poe.groups.doc.tasks.linkcheck]
cmd = """
sphinx-build \
--builder=linkcheck \
Expand All @@ -325,29 +264,82 @@ env = {PYTHONWARNINGS = ""}
executor = {group = "doc"}
help = "Check external links in the documentation (requires internet connection)"

[tool.poe.tasks.nb]
[tool.poe.groups.notebook]
heading = "Notebooks"

[tool.poe.groups.notebook.tasks.lab]
args = [{name = "paths", default = "", positional = true}]
cmd = "jupyter lab ${paths}"
executor = {group = "jupyter"}
help = "Launch Jupyter Lab"

[tool.poe.groups.notebook.tasks.nb]
args = [{name = "paths", default = "docs", multiple = true, positional = true}]
cmd = "pytest --nbmake --nbmake-timeout=0 ${paths}"
executor = {group = "notebooks", with = "nbmake"}
help = "Run all notebooks"

[tool.poe.tasks.style]
cmd = "pre-commit run --all-files"
executor = {group = "style"}
help = "Perform all linting, formatting, and spelling checks"
[tool.poe.groups.test]
heading = "Testing"

[tool.poe.groups.test.tasks.benchmark]
cmd = """
pytest benchmarks \
--benchmark-autosave \
--benchmark-json benchmarks/output.json \
--durations=0 \
-k benchmark
"""
executor = {extra = ["jax", "numba", "pwa"], group = "test"}
help = "Run benchmark tests and visualize performance"

[tool.poe.groups.test.tasks.cov]
cmd = """
pytest \
--cov=tensorwaves \
--cov-fail-under=85 \
--cov-report=html \
--cov-report=xml \
${paths}
"""
executor = {extra = ["jax", "numba", "pwa"], group = "test"}
help = "Compute how much of the source code is covered by tests"

[[tool.poe.groups.test.tasks.cov.args]]
default = ""
multiple = true
name = "paths"
positional = true

[tool.poe.groups.test.tasks.jax]
cmd = """
pytest \
-k 'benchmark or not benchmark' \
-k 'not (ampform or four_momenta or numba or tensorflow or tf)' \
--benchmark-disable \
${paths}
"""
executor = {extra = "jax", group = "test"}
help = "Run tests with JAX only"

[[tool.poe.groups.test.tasks.jax.args]]
default = "src tests"
multiple = true
name = "paths"
positional = true

[tool.poe.tasks.test]
[tool.poe.groups.test.tasks.test]
cmd = "pytest --benchmark-disable -m 'slow or not slow' ${paths}"
executor = {extra = ["jax", "numba", "pwa"], group = "test"}
help = "Run all unit tests"

[[tool.poe.tasks.test.args]]
[[tool.poe.groups.test.tasks.test.args]]
default = "src tests"
multiple = true
name = "paths"
positional = true

[tool.poe.tasks.test-all]
[tool.poe.groups.test.tasks.test-all]
help = "Run all tests on each supported Python version"
sequence = [
{ref = "test-py310 ${paths}"},
Expand All @@ -356,30 +348,48 @@ sequence = [
{ref = "test-py313 ${paths}"},
]

[[tool.poe.tasks.test-all.args]]
[[tool.poe.groups.test.tasks.test-all.args]]
default = ""
multiple = true
name = "paths"
positional = true

[tool.poe.tasks.test-py310]
[tool.poe.groups.test.tasks.test-py310]
env = {UV_PYTHON = "3.10"}
ref = "test"

[tool.poe.tasks.test-py311]
[tool.poe.groups.test.tasks.test-py311]
env = {UV_PYTHON = "3.11"}
ref = "test"

[tool.poe.tasks.test-py312]
[tool.poe.groups.test.tasks.test-py312]
env = {UV_PYTHON = "3.12"}
ref = "test"

[tool.poe.tasks.test-py313]
[tool.poe.groups.test.tasks.test-py313]
env = {UV_PYTHON = "3.13"}
ref = "test"

[tool.poe.tasks.all]
help = "Run all continuous integration (CI) tasks locally"
ignore_fail = "return_non_zero"
sequence = [
"benchmark",
"cov",
"docnb-force",
"linkcheck",
"style",
"test-all",
]

[tool.poe.tasks.style]
cmd = "pre-commit run --all-files"
executor = {group = "style"}
help = "Perform all linting, formatting, and spelling checks"

[tool.poe.tasks.upgrade]
executor = {type = "simple"}
help = "Upgrade lock files"
parallel = [
{cmd = "pre-commit autoupdate -j8"},
{cmd = "uv lock --upgrade"},
Expand Down
2 changes: 1 addition & 1 deletion src/tensorwaves/data/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def from_sympy(
for variable_name, expr in expanded_expressions.items():
function = _lambdify_normal_or_fast(
expr,
ordered_symbols, # ty:ignore[invalid-argument-type]
ordered_symbols,
backend,
use_cse=use_cse,
use_jit=use_jit,
Expand Down
10 changes: 7 additions & 3 deletions src/tensorwaves/function/_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ def get_jit_compile_dectorator(
backends_supporting_jit = {"jax", "numba"}
if backend.lower() in backends_supporting_jit:
return jit_compile(backend)
return lambda x: x
return _do_not_compile
if use_jit:
return jit_compile(backend)
return lambda x: x
return _do_not_compile


def jit_compile(backend: str) -> Callable[[Callable[P, T]], Callable[P, T]]:
Expand All @@ -96,7 +96,11 @@ def jit_compile(backend: str) -> Callable[[Callable[P, T]], Callable[P, T]]:

msg = f"Backend {backend} does not yet support JIT compilation"
warn(msg, category=UserWarning, stacklevel=3)
return lambda x: x
return _do_not_compile


def _do_not_compile(function: Callable[P, T]) -> Callable[P, T]:
return function


def raise_missing_module_error(module_name: str, *, extras_require: str = "") -> None:
Expand Down
Loading
Loading