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: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ jobs:
python-version: "3.13"
test:
uses: ComPWA/actions/.github/workflows/test.yml@826112415aa683bb2d73df87e84444a047f8cad7 # v4.1.8
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
coverage-python-version: "3.13"
macos-python-version: "3.11"
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
- id: check-useless-excludes

- repo: https://github.com/ComPWA/policy
rev: 0.10.1
rev: 0.10.3
hooks:
- id: check-dev-files

Expand Down
20 changes: 9 additions & 11 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ build:
os: ubuntu-24.04
tools:
python: "3.13"
commands:
- |-
export PIXI_HOME=$READTHEDOCS_VIRTUALENV_PATH
curl -fsSL https://pixi.sh/install.sh | bash
pixi global install graphviz uv
- |-
export UV_LINK_MODE=copy
uvx --from poethepoet poe doc
mkdir -p $READTHEDOCS_OUTPUT
mv docs/_build/html $READTHEDOCS_OUTPUT

apt_packages:
- graphviz
sphinx:
configuration: docs/conf.py
fail_on_warning: true
python:
install:
- method: uv
command: sync
groups:
- doc
7 changes: 1 addition & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
}
],
"livePreview.defaultPreviewPath": "docs/_build/html",
"multiDiffEditor.experimental.enabled": true,
"notebook.codeActionsOnSave": {
"notebook.source.organizeImports": "explicit"
},
Expand All @@ -72,9 +71,5 @@
"testing.showCoverageInExplorer": true,
"ty.completions.autoImport": false,
"ty.diagnosticMode": "workspace",
"ty.importStrategy": "fromEnvironment",
"yaml.schemas": {
"https://citation-file-format.github.io/1.2.0/schema.json": "CITATION.cff",
"https://json.schemastore.org/github-workflow.json": "./.github/workflows/requirements.yml"
}
"ty.importStrategy": "fromEnvironment"
}
8 changes: 4 additions & 4 deletions benchmarks/ampform.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import tensorwaves as tw
from tensorwaves.data import (
IntensityDistributionGenerator,
PhaseSpaceGenerator,
SympyDataTransformer,
TFPhaseSpaceGenerator,
TFUniformRealNumberGenerator,
TFWeightedPhaseSpaceGenerator,
WeightedPhaseSpaceGenerator,
)
from tensorwaves.function.sympy import create_parametrized_function

Expand Down Expand Up @@ -85,14 +85,14 @@ def generate_data(

initial_state_mass = reaction.initial_state[-1].mass
final_state_masses = {i: p.mass for i, p in final_state.items()}
phsp_generator = TFPhaseSpaceGenerator(
phsp_generator = PhaseSpaceGenerator(
initial_state_mass, final_state_masses, backend="tensorflow"
)
phsp = phsp_generator.generate(
phsp_sample_size, rng=TFUniformRealNumberGenerator(seed=0)
)

weighted_phsp_generator = TFWeightedPhaseSpaceGenerator(
weighted_phsp_generator = WeightedPhaseSpaceGenerator(
initial_state_mass, final_state_masses, backend="tensorflow"
)
data_generator = IntensityDistributionGenerator(
Expand Down
23 changes: 8 additions & 15 deletions docs/amplitude-analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The {class}`~qrules.transition.ReactionInfo` class defines the constraints of the phase space. As such, we have enough information to generate a **phase-space sample** for this particle reaction. We do this with a {class}`.TFPhaseSpaceGenerator` class, which is a {class}`.DataGenerator` for a {obj}`.DataSample` of **four-momenta** arrays (using {obj}`tensorflow <tf.Tensor>` and the [`phasespace`](https://phasespace.readthedocs.io) package as a back-end). We also need to construct a {class}`.RealNumberGenerator` that can generate random numbers. {class}`.TFUniformRealNumberGenerator` is the natural choice here. See {doc}`/usage/phase-space` for an overview of the available generators.\n",
"The {class}`~qrules.transition.ReactionInfo` class defines the constraints of the phase space. As such, we have enough information to generate a **phase-space sample** for this particle reaction. We do this with an {class}`.EvtGenPhaseSpaceGenerator`, which is a {class}`.DataGenerator` for a {obj}`.DataSample` of **four-momenta** arrays that uses [EvtGen](https://gitlab.cern.ch/evtgen/evtgen) as a back-end. We also need to construct a {class}`.RealNumberGenerator` that can generate random numbers, such as a {class}`.NumpyUniformRNG`. See {doc}`/usage/phase-space` for an overview of the available generators.\n",
"\n",
"As opposed to the main [](compwa-step-2) of the main usage example page, we will generate a **deterministic** data sample. This can be done by feeding a {class}`.RealNumberGenerator` with a specific {attr}`~.RealNumberGenerator.seed` and giving that generator to the {meth}`.TFPhaseSpaceGenerator.generate` method:"
"As opposed to the main [](compwa-step-2) of the main usage example page, we will generate a **deterministic** data sample. This can be done by feeding a {class}`.RealNumberGenerator` with a specific {attr}`~.RealNumberGenerator.seed` and giving that generator to the {meth}`.EvtGenPhaseSpaceGenerator.generate` method:"
]
},
{
Expand Down Expand Up @@ -375,10 +375,10 @@
},
"outputs": [],
"source": [
"from tensorwaves.data import NumpyUniformRNG, TFPhaseSpaceGenerator\n",
"from tensorwaves.data import EvtGenPhaseSpaceGenerator, NumpyUniformRNG\n",
"\n",
"rng = NumpyUniformRNG(seed=0)\n",
"phsp_generator = TFPhaseSpaceGenerator(\n",
"phsp_generator = EvtGenPhaseSpaceGenerator(\n",
" initial_state_mass=reaction.initial_state[-1].mass,\n",
" final_state_masses={i: p.mass for i, p in reaction.final_state.items()},\n",
")\n",
Expand Down Expand Up @@ -462,7 +462,7 @@
"source": [
"'Data samples' are more complicated than phase space samples in that they represent the intensity profile resulting from a reaction. You therefore need a {class}`.Function` object that expresses an intensity distribution as well as a phase space over which to generate that distribution. We call such a data sample an **intensity-based sample**.\n",
"\n",
"An intensity-based sample is generated over a phase space sample using the {class}`.IntensityDistributionGenerator`. Its usage is similar to {class}`.TFPhaseSpaceGenerator`, but now you have to provide a {obj}`.Function` as well as a {obj}`.DataTransformer` that is used to transform the four-momentum phase space sample to a data sample that can be understood by the {obj}`.Function`.\n",
"An intensity-based sample is generated over a phase space sample using the {class}`.IntensityDistributionGenerator`. Its usage is similar to {class}`.EvtGenPhaseSpaceGenerator`, but now you have to provide a {obj}`.Function` as well as a {obj}`.DataTransformer` that is used to transform the four-momentum phase space sample to a data sample that can be understood by the {obj}`.Function`.\n",
"\n",
"Now, recall that in [](compwa-step-1), we used the helicity formalism to mathematically express the reaction in terms of an amplitude model. TensorWaves needs to convert this {obj}`~ampform.helicity.HelicityModel` to a {obj}`.Function` object that can perform fast computations. This can be done with {func}`.create_parametrized_function`:"
]
Expand Down Expand Up @@ -554,17 +554,10 @@
},
"outputs": [],
"source": [
"from tensorwaves.data import (\n",
" IntensityDistributionGenerator,\n",
" TFWeightedPhaseSpaceGenerator,\n",
")\n",
"from tensorwaves.data import IntensityDistributionGenerator\n",
"\n",
"weighted_phsp_generator = TFWeightedPhaseSpaceGenerator(\n",
" initial_state_mass=reaction.initial_state[-1].mass,\n",
" final_state_masses={i: p.mass for i, p in reaction.final_state.items()},\n",
")\n",
"data_generator = IntensityDistributionGenerator(\n",
" domain_generator=weighted_phsp_generator,\n",
" domain_generator=phsp_generator,\n",
" function=intensity_func,\n",
" domain_transformer=helicity_transformer,\n",
")\n",
Expand All @@ -584,7 +577,7 @@
"\n",
":::{note}\n",
"\n",
"Instead of constructing a {class}`.TFWeightedPhaseSpaceGenerator`, it's also possible to just reuse the **unweighted** {class}`.TFPhaseSpaceGenerator` that we constructed previously. This is, however, a bit slower, because the {class}`.TFPhaseSpaceGenerator` also uses a hit-and-miss strategy.\n",
"The {class}`.EvtGenPhaseSpaceGenerator` provides **unweighted** events, so the {class}`.IntensityDistributionGenerator` only has to perform hit-and-miss over the intensity. A {class}`.WeightedPhaseSpaceGenerator` provides weighted events instead, which the {class}`.IntensityDistributionGenerator` takes into account in the same hit-and-miss step. See {doc}`/usage/phase-space` for a comparison.\n",
"\n",
":::"
]
Expand Down
4 changes: 2 additions & 2 deletions docs/amplitude-analysis/analytic-continuation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"from IPython.display import Markdown, Math\n",
"\n",
"from tensorwaves.data import (\n",
" EvtGenPhaseSpaceGenerator,\n",
" NumpyUniformRNG,\n",
" SympyDataTransformer,\n",
" TFPhaseSpaceGenerator,\n",
")\n",
"from tensorwaves.function.sympy import create_parametrized_function\n",
"\n",
Expand Down Expand Up @@ -168,7 +168,7 @@
" model.kinematic_variables, backend=\"numpy\"\n",
")\n",
"rng = NumpyUniformRNG(seed=0)\n",
"phsp_generator = TFPhaseSpaceGenerator(\n",
"phsp_generator = EvtGenPhaseSpaceGenerator(\n",
" initial_state_mass=reaction.initial_state[-1].mass,\n",
" final_state_masses={i: p.mass for i, p in reaction.final_state.items()},\n",
")\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ conda install -c conda-forge ampform phasespace
:::
::::

To generate phase space samples with [EvtGen](https://gitlab.cern.ch/evtgen/evtgen), install [`pyevtgen`](https://github.com/redeboer/pyevtgen-test) with the `evtgen` extra and use {class}`.EvtGenPhaseSpaceGenerator`. This package is not yet on PyPI and is available from [its package index](https://redeboer.github.io/pyevtgen-test):
The examples in this documentation generate phase space samples with [EvtGen](https://gitlab.cern.ch/evtgen/evtgen). To do the same, install [`pyevtgen`](https://github.com/redeboer/pyevtgen-test) with the `evtgen` extra and use {class}`.EvtGenPhaseSpaceGenerator`. This package is not yet on PyPI and is available from [its package index](https://redeboer.github.io/pyevtgen-test):

```shell
uv pip install "tensorwaves[evtgen]" --index https://redeboer.github.io/pyevtgen-test/simple
Expand All @@ -59,7 +59,7 @@ pip install tensorwaves[jax,scipy,tf]
pip install tensorwaves[all] # all runtime dependencies
```

The `phsp` and `pwa` extras generate phase space samples with NumPy and do not install TensorFlow. To generate them with TensorFlow or JAX, install the `tf` or `jax` extra as well and select it with the `backend` argument of {class}`.TFPhaseSpaceGenerator` or {class}`.TFWeightedPhaseSpaceGenerator`.
The `phsp` and `pwa` extras generate phase space samples with NumPy and do not install TensorFlow. To generate them with TensorFlow or JAX, install the `tf` or `jax` extra as well and select it with the `backend` argument of {class}`.PhaseSpaceGenerator` or {class}`.WeightedPhaseSpaceGenerator`.

## Backend precision

Expand Down
2 changes: 1 addition & 1 deletion docs/usage/basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@
"metadata": {},
"source": [
"```{note}\n",
"In PWA, the sample on which we perform hit-and-miss is not uniform, because the available space is limited by the masses of the initial and final state (phase space). See {class}`.TFPhaseSpaceGenerator` and {ref}`amplitude-analysis:Step 2: Generate data`.\n",
"In PWA, the sample on which we perform hit-and-miss is not uniform, because the available space is limited by the masses of the initial and final state (phase space). See {class}`.PhaseSpaceGenerator` and {ref}`amplitude-analysis:Step 2: Generate data`.\n",
"```"
]
},
Expand Down
Loading