Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: update lock files #27

Merged
merged 14 commits into from
Jan 13, 2025
Merged
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
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ concurrency:
cancel-in-progress: |-
${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }}

env:
PYTHONHASHSEED: "0"

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

- repo: https://github.com/ComPWA/policy
rev: 0.5.5
rev: 0.5.15
hooks:
- id: check-dev-files
args:
Expand All @@ -24,7 +24,7 @@ repos:
- id: remove-empty-tags

- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
rev: 0.8.1
hooks:
- id: nbstripout
args:
Expand Down Expand Up @@ -52,7 +52,7 @@ repos:
metadata.vscode

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1
rev: v0.9.1
hooks:
- id: ruff
args: [--fix]
Expand All @@ -76,7 +76,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/ComPWA/prettier-pre-commit
rev: v3.3.3
rev: v3.4.2
hooks:
- id: prettier

Expand All @@ -86,7 +86,7 @@ repos:
- id: taplo-format

- repo: https://github.com/pappasam/toml-sort
rev: v0.23.1
rev: v0.24.2
hooks:
- id: toml-sort
args:
Expand All @@ -104,11 +104,11 @@ repos:
)$

- repo: https://github.com/ComPWA/pyright-pre-commit
rev: v1.1.386
rev: v1.1.391
hooks:
- id: pyright

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.4.27
rev: 0.5.18
hooks:
- id: uv-lock
7 changes: 7 additions & 0 deletions .taplo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"mhutchie.git-graph",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"ms-toolsai.vscode-jupyter-cell-tags",
"ms-vscode.live-server",
"ms-vsliveshare.vsliveshare",
"oijaz.unicode-latex",
Expand All @@ -28,6 +30,7 @@
"ms-python.isort",
"ms-python.mypy-type-checker",
"ms-python.pylint",
"ms-toolsai.vscode-jupyter-slideshow",
"streetsidesoftware.code-spell-checker",
"travisillig.vscode-json-stable-stringify",
"tyriar.sort-lines"
Expand Down
170 changes: 88 additions & 82 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ split-on-trailing-comma = false
"PLW0603",
"S101",
"T20",
"TCH00",
"TC00",
]
"docs/*" = [
"E402",
Expand All @@ -201,98 +201,104 @@ sort_first = [
"build-system",
"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 =
docnb-force,
linkcheck,
sty,
skip_install = True
skip_missing_interpreters = True
skipsdist = True
env_list = [
"docnb-force",
"linkcheck",
"sty",
]
no_package = true
requires = ["tox>=4.21.0"]
skip_install = true
skip_missing_interpreters = true

[testenv]
passenv = *
setenv =
PYTHONHASHSEED = 0
[tool.tox.env_run_base]
pass_env = ["*"]

[testenv:doc]
allowlist_externals =
sphinx-build
commands =
sphinx-build \
--builder=html \
--fail-on-warning \
--keep-going \
--show-traceback \
docs/ docs/_build/html
description = Build documentation and API through Sphinx
[tool.tox.env.doc]
allowlist_externals = ["sphinx-build"]
commands = [
[
"sphinx-build",
"--builder=html",
"--fail-on-warning",
"--keep-going",
"--show-traceback",
"docs/",
"docs/_build/html",
],
]
description = "Build documentation and API through Sphinx"
set_env.PYTHONWARNINGS = ""

[testenv:docnb]
base = doc
description = {[testenv:doc]description} with cached notebook execution
setenv =
{[testenv:doc]setenv}
EXECUTE_NB = yes
[tool.tox.env.doclive]
allowlist_externals = ["sphinx-autobuild"]
commands = [
[
"sphinx-autobuild",
"--open-browser",
"--port=0",
"--re-ignore='.*/__pycache__/.*'",
"--re-ignore='.*/.ipynb_checkpoints/.*'",
"--re-ignore='.*/.virtual_documents/.*'",
"--re-ignore='.*\\.tmp'",
"--watch",
"docs",
"docs/",
"docs/_build/html",
],
]
description = "Set up a server to directly preview changes to the HTML pages"

[testenv:docnb-force]
base = doc
description = {[testenv:doc]description} with notebook execution (no cache)
setenv =
{[testenv:doc]setenv}
FORCE_EXECUTE_NB = yes
[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"},
]

[testenv:doclive]
allowlist_externals =
sphinx-autobuild
commands =
sphinx-autobuild \
--open-browser \
--port=0 \
--re-ignore='.*/__pycache__/.*' \
--re-ignore='.*/.ipynb_checkpoints/.*' \
--re-ignore='.*/.virtual_documents/.*' \
--re-ignore='.*\\.tmp' \
--watch docs \
docs/ docs/_build/html
description = Set up a server to directly preview changes to the HTML pages
[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"},
]

[testenv:docnblive]
base = doclive
description = {[testenv:doclive]description} with cached notebook execution
setenv =
{[testenv:doclive]setenv}
EXECUTE_NB = yes
[tool.tox.env.docnblive]
base = ["tool.tox.env.doclive", "tool.tox.env_run_base"]
description = "{[tool.tox.env.doclive]description} with cached notebook execution"
set_env = [
{replace = "ref", of = ["tool.tox.env.doclive.set_env"]},
{EXECUTE_NB = "yes"},
]

[testenv:linkcheck]
allowlist_externals =
sphinx-build
commands =
sphinx-build \
--builder=linkcheck \
--show-traceback \
docs/ docs/_build/linkcheck
description = Check external links in the documentation (requires internet connection)
setenv =
PYTHONWARNINGS =
[tool.tox.env.linkcheck]
allowlist_externals = ["sphinx-build"]
commands = [
[
"sphinx-build",
"--builder=linkcheck",
"--show-traceback",
"docs/",
"docs/_build/linkcheck",
],
]
description = "Check external links in the documentation (requires internet connection)"
set_env.PYTHONWARNINGS = ""

[testenv:nb]
allowlist_externals =
pytest
commands =
pytest --nbmake {posargs:docs}
description = Run all notebooks with pytest
[tool.tox.env.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
"""
[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"
24 changes: 10 additions & 14 deletions scripts/execute_jax_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@
format="%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
LOGGER = logging.getLogger()
_LOGGER = logging.getLogger()
mute_jax_warnings()

yaml.add_representer(defaultdict, Representer.represent_dict)

BENCHMARK_CASES = [
Expand Down Expand Up @@ -78,7 +77,7 @@ def main() -> int:
existing_benchmark = t.get(n)
if existing_benchmark is not None:
if all(len(v) == NUMBER_OF_RUNS for v in existing_benchmark.values()):
logging.warning(f"Benchmark for {n:,} events already exists")
_LOGGER.warning(f"Benchmark for {n:,} events already exists")
progress_bar.update(NUMBER_OF_RUNS)
continue
t[n] = defaultdict(list)
Expand Down Expand Up @@ -118,33 +117,30 @@ def create_amplitude_model() -> AmplitudeModel:
def prepare_functions(
model: AmplitudeModel,
) -> tuple[ParametrizedBackendFunction, PositionalArgumentFunction]:
original_log_level = LOGGER.getEffectiveLevel()
LOGGER.setLevel(logging.INFO)
logging.info("Unfolding intensity expression")
_LOGGER.info("Unfolding intensity expression")
unfolded_intensity_expr = perform_cached_doit(model.full_expression)
logging.info("Substituting parameters")
_LOGGER.info("Substituting parameters")
substituted_expr = unfolded_intensity_expr.xreplace(model.parameter_defaults)
logging.info("Lambdifying full intensity expression")
_LOGGER.info("Lambdifying full intensity expression")
parametrized_func = create_parametrized_function(
unfolded_intensity_expr,
parameters=model.parameter_defaults,
backend="jax",
)
logging.info("Lambdifying substituted intensity expression")
_LOGGER.info("Lambdifying substituted intensity expression")
substituted_func = create_function(substituted_expr, backend="jax")
logging.info("Finished function lambdification")
LOGGER.setLevel(original_log_level)
_LOGGER.info("Finished function lambdification")
return parametrized_func, substituted_func


def generate_sample(
model: AmplitudeModel, n_events: int, seed: int | None = None
) -> DataSample:
transformer = create_data_transformer(model)
original_log_level = LOGGER.getEffectiveLevel()
LOGGER.setLevel(logging.ERROR)
original_log_level = _LOGGER.getEffectiveLevel()
_LOGGER.setLevel(logging.ERROR)
phsp_sample = generate_phasespace_sample(model.decay, n_events, seed)
LOGGER.setLevel(original_log_level)
_LOGGER.setLevel(original_log_level)
return transformer(phsp_sample)


Expand Down
Loading