tensorwaves 0.4.19__tar.gz → 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/PKG-INFO +7 -6
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/README.md +1 -1
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/benchmarks/ampform.py +8 -6
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/benchmarks/expression.py +2 -2
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/docs/amplitude-analysis/analytic-continuation.ipynb +4 -8
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/docs/amplitude-analysis/phase-space.ipynb +17 -19
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/docs/amplitude-analysis.ipynb +10 -13
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/docs/install.md +4 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/docs/usage/basics.ipynb +1 -1
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/pyproject.toml +28 -9
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/data/__init__.py +2 -2
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/data/phasespace.py +12 -13
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/data/rng.py +2 -2
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/function/_backend.py +1 -1
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/function/sympy/__init__.py +1 -1
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/version.py +3 -3
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves.egg-info/PKG-INFO +7 -6
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves.egg-info/requires.txt +3 -2
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves.egg-info/scm_version.json +2 -2
- tensorwaves-0.5.0/tests/conftest.py +54 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/data/test_data.py +3 -2
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/data/test_phasespace.py +60 -29
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/data/test_rng.py +2 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/data/test_transform.py +1 -1
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/function/test_ampform.py +3 -3
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/function/test_backend.py +11 -4
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/function/test_sympy.py +4 -4
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/optimizer/test_fit_simple_model.py +1 -1
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/test_config.py +1 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/test_estimator.py +1 -1
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/uv.lock +79 -159
- tensorwaves-0.4.19/tests/conftest.py +0 -20
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.binder/apt.txt +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.binder/postBuild +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.binder/runtime.txt +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.cspell.json +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.editorconfig +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.envrc +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.gitattributes +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.github/dependabot.yml +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.github/release-drafter.yml +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.github/workflows/benchmark.yml +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.github/workflows/cd.yml +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.github/workflows/ci.yml +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.github/workflows/clean-caches.yml +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.github/workflows/lock.yml +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.github/workflows/pr-linting.yml +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.github/workflows/redirect-gh-pages.yml +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.github/workflows/release-drafter.yml +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.gitignore +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.pre-commit-config.yaml +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.prettierignore +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.python-version +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.readthedocs.yml +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.vscode/extensions.json +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.vscode/launch.json +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/.vscode/settings.json +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/CITATION.cff +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/CONTRIBUTING.md +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/LICENSE +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/benchmarks/__init__.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/benchmarks/conftest.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/benchmarks/precision.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/benchmarks/unbinned_nll.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/codecov.yml +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/docs/.gitignore +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/docs/_static/favicon.ico +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/docs/_static/linebreaks-api.css +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/docs/_static/mermaid.css +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/docs/conf.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/docs/index.md +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/docs/tensorflow.txt +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/docs/usage/binned-fit.ipynb +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/docs/usage/caching.ipynb +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/docs/usage/chi-squared.ipynb +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/docs/usage/faster-lambdify.ipynb +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/docs/usage/unbinned-fit.ipynb +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/docs/usage.ipynb +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/setup.cfg +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/__init__.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/config.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/data/_attrs.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/data/_data_sample.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/data/transform.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/estimator.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/function/__init__.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/function/sympy/_printer.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/interface.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/optimizer/__init__.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/optimizer/callbacks.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/optimizer/minuit.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/optimizer/parameter.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/optimizer/scipy.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves/py.typed +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves.egg-info/SOURCES.txt +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves.egg-info/dependency_links.txt +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves.egg-info/scm_file_list.json +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/src/tensorwaves.egg-info/top_level.txt +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/__init__.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/data/__init__.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/function/__init__.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/function/test_function.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/optimizer/__init__.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/optimizer/test_callbacks.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/optimizer/test_gradient.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/optimizer/test_minuit.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/optimizer/test_parameter.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/optimizer/test_scipy.py +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/output/.gitignore +0 -0
- {tensorwaves-0.4.19 → tensorwaves-0.5.0}/tests/test_interface.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tensorwaves
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Python fitter package for multiple computational back-ends
|
|
5
5
|
Author-email: Common Partial Wave Analysis <compwa-admin@ep1.rub.de>
|
|
6
6
|
Maintainer-email: compwa-admin@ep1.rub.de
|
|
@@ -20,6 +20,8 @@ Classifier: Programming Language :: Python
|
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.11
|
|
21
21
|
Classifier: Programming Language :: Python :: 3.12
|
|
22
22
|
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
23
25
|
Classifier: Topic :: Scientific/Engineering
|
|
24
26
|
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
25
27
|
Classifier: Typing :: Typed
|
|
@@ -39,16 +41,15 @@ Requires-Dist: jaxlib; extra == "jax"
|
|
|
39
41
|
Provides-Extra: numba
|
|
40
42
|
Requires-Dist: numba; extra == "numba"
|
|
41
43
|
Provides-Extra: phsp
|
|
42
|
-
Requires-Dist: phasespace
|
|
43
|
-
Requires-Dist: tensorwaves[tf]; extra == "phsp"
|
|
44
|
+
Requires-Dist: phasespace>=2.0.0; extra == "phsp"
|
|
44
45
|
Provides-Extra: pwa
|
|
45
46
|
Requires-Dist: ampform[viz]>=0.12.0; extra == "pwa"
|
|
46
47
|
Requires-Dist: tensorwaves[phsp]; extra == "pwa"
|
|
47
48
|
Provides-Extra: scipy
|
|
48
49
|
Requires-Dist: scipy>=1; extra == "scipy"
|
|
49
50
|
Provides-Extra: tf
|
|
50
|
-
Requires-Dist: tensorboard; extra == "tf"
|
|
51
|
-
Requires-Dist: tensorflow>=2.12; extra == "tf"
|
|
51
|
+
Requires-Dist: tensorboard; python_version < "3.14" and extra == "tf"
|
|
52
|
+
Requires-Dist: tensorflow>=2.12; python_version < "3.14" and extra == "tf"
|
|
52
53
|
Dynamic: license-file
|
|
53
54
|
|
|
54
55
|
# TensorWaves
|
|
@@ -64,7 +65,7 @@ Dynamic: license-file
|
|
|
64
65
|
[](https://colab.research.google.com/github/ComPWA/tensorwaves/blob/stable)
|
|
65
66
|
[](https://github.dev/ComPWA/tensorwaves)
|
|
66
67
|
|
|
67
|
-
[](https://tensorwaves.readthedocs.io)
|
|
68
69
|
[](https://results.pre-commit.ci/latest/github/ComPWA/tensorwaves/main)
|
|
69
70
|
[](https://github.com/ComPWA/tensorwaves/actions/workflows/ci.yml)
|
|
70
71
|
[](https://codecov.io/gh/ComPWA/tensorwaves)
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
[](https://colab.research.google.com/github/ComPWA/tensorwaves/blob/stable)
|
|
12
12
|
[](https://github.dev/ComPWA/tensorwaves)
|
|
13
13
|
|
|
14
|
-
[](https://tensorwaves.readthedocs.io)
|
|
15
15
|
[](https://results.pre-commit.ci/latest/github/ComPWA/tensorwaves/main)
|
|
16
16
|
[](https://github.com/ComPWA/tensorwaves/actions/workflows/ci.yml)
|
|
17
17
|
[](https://codecov.io/gh/ComPWA/tensorwaves)
|
|
@@ -10,10 +10,10 @@ import pytest
|
|
|
10
10
|
import tensorwaves as tw
|
|
11
11
|
from tensorwaves.data import (
|
|
12
12
|
IntensityDistributionGenerator,
|
|
13
|
+
PhaseSpaceGenerator,
|
|
13
14
|
SympyDataTransformer,
|
|
14
|
-
TFPhaseSpaceGenerator,
|
|
15
15
|
TFUniformRealNumberGenerator,
|
|
16
|
-
|
|
16
|
+
WeightedPhaseSpaceGenerator,
|
|
17
17
|
)
|
|
18
18
|
from tensorwaves.function.sympy import create_parametrized_function
|
|
19
19
|
|
|
@@ -85,13 +85,15 @@ def generate_data(
|
|
|
85
85
|
|
|
86
86
|
initial_state_mass = reaction.initial_state[-1].mass
|
|
87
87
|
final_state_masses = {i: p.mass for i, p in final_state.items()}
|
|
88
|
-
phsp_generator =
|
|
88
|
+
phsp_generator = PhaseSpaceGenerator(
|
|
89
|
+
initial_state_mass, final_state_masses, backend="tensorflow"
|
|
90
|
+
)
|
|
89
91
|
phsp = phsp_generator.generate(
|
|
90
92
|
phsp_sample_size, rng=TFUniformRealNumberGenerator(seed=0)
|
|
91
93
|
)
|
|
92
94
|
|
|
93
|
-
weighted_phsp_generator =
|
|
94
|
-
initial_state_mass, final_state_masses
|
|
95
|
+
weighted_phsp_generator = WeightedPhaseSpaceGenerator(
|
|
96
|
+
initial_state_mass, final_state_masses, backend="tensorflow"
|
|
95
97
|
)
|
|
96
98
|
data_generator = IntensityDistributionGenerator(
|
|
97
99
|
weighted_phsp_generator, function, domain_transformer=converter
|
|
@@ -160,7 +162,7 @@ class TestJPsiToGammaPiPi:
|
|
|
160
162
|
}
|
|
161
163
|
|
|
162
164
|
@pytest.mark.benchmark(group="data", min_rounds=1)
|
|
163
|
-
@pytest.mark.parametrize("backend", ["jax", "numpy", "
|
|
165
|
+
@pytest.mark.parametrize("backend", ["jax", "numpy", "tensorflow"])
|
|
164
166
|
@pytest.mark.parametrize("size", [10_000])
|
|
165
167
|
def test_data(self, backend, benchmark, model, size):
|
|
166
168
|
n_data = size
|
|
@@ -100,7 +100,7 @@ def generate_data_and_domain(
|
|
|
100
100
|
|
|
101
101
|
|
|
102
102
|
@pytest.mark.benchmark(group="data-simple")
|
|
103
|
-
@pytest.mark.parametrize("backend", ["jax", "numpy", "numba", "
|
|
103
|
+
@pytest.mark.parametrize("backend", ["jax", "numpy", "numba", "tensorflow"])
|
|
104
104
|
@pytest.mark.parametrize("size", [3_000])
|
|
105
105
|
def test_data(backend, benchmark, size):
|
|
106
106
|
domain, data = benchmark(
|
|
@@ -111,7 +111,7 @@ def test_data(backend, benchmark, size):
|
|
|
111
111
|
|
|
112
112
|
|
|
113
113
|
@pytest.mark.benchmark(group="fit-simple")
|
|
114
|
-
@pytest.mark.parametrize("backend", ["jax", "numpy", "numba", "
|
|
114
|
+
@pytest.mark.parametrize("backend", ["jax", "numpy", "numba", "tensorflow"])
|
|
115
115
|
@pytest.mark.parametrize("optimizer_type", [Minuit2, ScipyMinimizer])
|
|
116
116
|
@pytest.mark.parametrize("size", [1_000])
|
|
117
117
|
def test_fit(
|
{tensorwaves-0.4.19 → tensorwaves-0.5.0}/docs/amplitude-analysis/analytic-continuation.ipynb
RENAMED
|
@@ -31,11 +31,7 @@
|
|
|
31
31
|
"import qrules\n",
|
|
32
32
|
"from IPython.display import Markdown, Math\n",
|
|
33
33
|
"\n",
|
|
34
|
-
"from tensorwaves.data import
|
|
35
|
-
" SympyDataTransformer,\n",
|
|
36
|
-
" TFPhaseSpaceGenerator,\n",
|
|
37
|
-
" TFUniformRealNumberGenerator,\n",
|
|
38
|
-
")\n",
|
|
34
|
+
"from tensorwaves.data import PhaseSpaceGenerator, SympyDataTransformer, UniformRNG\n",
|
|
39
35
|
"from tensorwaves.function.sympy import create_parametrized_function\n",
|
|
40
36
|
"\n",
|
|
41
37
|
"logging.getLogger(\"tensorwaves.data\").setLevel(logging.ERROR) # hide progress bars\n",
|
|
@@ -167,8 +163,8 @@
|
|
|
167
163
|
"helicity_transformer = SympyDataTransformer.from_sympy(\n",
|
|
168
164
|
" model.kinematic_variables, backend=\"numpy\"\n",
|
|
169
165
|
")\n",
|
|
170
|
-
"rng =
|
|
171
|
-
"phsp_generator =
|
|
166
|
+
"rng = UniformRNG(seed=0)\n",
|
|
167
|
+
"phsp_generator = PhaseSpaceGenerator(\n",
|
|
172
168
|
" initial_state_mass=reaction.initial_state[-1].mass,\n",
|
|
173
169
|
" final_state_masses={i: p.mass for i, p in reaction.final_state.items()},\n",
|
|
174
170
|
")\n",
|
|
@@ -232,7 +228,7 @@
|
|
|
232
228
|
"name": "python",
|
|
233
229
|
"nbconvert_exporter": "python",
|
|
234
230
|
"pygments_lexer": "ipython3",
|
|
235
|
-
"version": "3.13.
|
|
231
|
+
"version": "3.13.18"
|
|
236
232
|
}
|
|
237
233
|
},
|
|
238
234
|
"nbformat": 4,
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"cell_type": "markdown",
|
|
17
17
|
"metadata": {},
|
|
18
18
|
"source": [
|
|
19
|
-
"Amplitude analysis needs samples of four-momenta that are distributed uniformly over the phase space of a decay. {class}`.
|
|
19
|
+
"Amplitude analysis needs samples of four-momenta that are distributed uniformly over the phase space of a decay. {class}`.PhaseSpaceGenerator` produces such samples with [`phasespace`](https://phasespace.readthedocs.io), which can run on NumPy, TensorFlow, or JAX. `phasespace` generates *weighted* events, so {class}`.PhaseSpaceGenerator` turns them into unweighted events with a hit-and-miss step: an event is kept if a uniform random number is below its weight. {class}`.WeightedPhaseSpaceGenerator` returns the weighted events instead. This page shows how to select a backend and how the `adaptive_max_weight` option makes the hit-and-miss step faster without changing the generated distribution."
|
|
20
20
|
]
|
|
21
21
|
},
|
|
22
22
|
{
|
|
@@ -60,11 +60,11 @@
|
|
|
60
60
|
"metadata": {},
|
|
61
61
|
"outputs": [],
|
|
62
62
|
"source": [
|
|
63
|
-
"from tensorwaves.data import
|
|
63
|
+
"from tensorwaves.data import PhaseSpaceGenerator, UniformRNG\n",
|
|
64
64
|
"\n",
|
|
65
65
|
"generators = {}\n",
|
|
66
66
|
"for backend in [\"numpy\", \"tensorflow\", \"jax\"]:\n",
|
|
67
|
-
" generator =
|
|
67
|
+
" generator = PhaseSpaceGenerator(\n",
|
|
68
68
|
" initial_state_mass=3.0969,\n",
|
|
69
69
|
" final_state_masses={0: 0.1350, 1: 0.1396, 2: 0.4937},\n",
|
|
70
70
|
" backend=backend,\n",
|
|
@@ -79,16 +79,18 @@
|
|
|
79
79
|
"source": [
|
|
80
80
|
"| `backend` | Extra | Use of the {class}`.RealNumberGenerator` |\n",
|
|
81
81
|
"| --- | --- | --- |\n",
|
|
82
|
-
"| `\"
|
|
83
|
-
"| `\"
|
|
84
|
-
"| `\"jax\"` | `phsp,jax` | any type only provides a seed
|
|
82
|
+
"| `\"numpy\"` (default) | `phsp` | {class}`.NumpyUniformRNG` is used directly, any other type only provides a seed |\n",
|
|
83
|
+
"| `\"tensorflow\"` | `phsp,tf` | {class}`.TFUniformRealNumberGenerator` is used directly, any other type only provides a seed |\n",
|
|
84
|
+
"| `\"jax\"` | `phsp,jax` | any type only provides a seed |\n",
|
|
85
|
+
"\n",
|
|
86
|
+
"The installation of these extras is described on {doc}`/install`."
|
|
85
87
|
]
|
|
86
88
|
},
|
|
87
89
|
{
|
|
88
90
|
"cell_type": "markdown",
|
|
89
91
|
"metadata": {},
|
|
90
92
|
"source": [
|
|
91
|
-
"Every backend is used through the same {meth}`~.
|
|
93
|
+
"Every backend is used through the same {meth}`~.PhaseSpaceGenerator.generate` method. The events of different backends are not identical, not even with the same seed, but they follow the same distribution: a uniform phase space sample shows up as a flat Dalitz plot within the kinematic boundary."
|
|
92
94
|
]
|
|
93
95
|
},
|
|
94
96
|
{
|
|
@@ -128,7 +130,7 @@
|
|
|
128
130
|
"cell_type": "markdown",
|
|
129
131
|
"metadata": {},
|
|
130
132
|
"source": [
|
|
131
|
-
"
|
|
133
|
+
"NumPy is the default choice, because it needs no additional dependencies and no compilation. TensorFlow and JAX compile functions on the first call, but are several times faster afterwards, so they are worth it when generating large or many samples for the same decay. TensorFlow reproduces samples from earlier TensorWaves versions, when combined with a {class}`.TFUniformRealNumberGenerator`. JAX can be useful if the rest of the analysis already uses it. {doc}`TR-037 <compwa-report:037/index>` benchmarks the backends and compares their distributions for three-body and four-body decays.\n",
|
|
132
134
|
"\n",
|
|
133
135
|
"There are two things to keep in mind:\n",
|
|
134
136
|
"\n",
|
|
@@ -170,12 +172,12 @@
|
|
|
170
172
|
},
|
|
171
173
|
"outputs": [],
|
|
172
174
|
"source": [
|
|
173
|
-
"from tensorwaves.data import
|
|
175
|
+
"from tensorwaves.data import WeightedPhaseSpaceGenerator\n",
|
|
174
176
|
"\n",
|
|
175
177
|
"n_particles = list(range(3, 9))\n",
|
|
176
178
|
"weights = {}\n",
|
|
177
179
|
"for n in n_particles:\n",
|
|
178
|
-
" weighted_generator =
|
|
180
|
+
" weighted_generator = WeightedPhaseSpaceGenerator(\n",
|
|
179
181
|
" initial_state_mass=5.0,\n",
|
|
180
182
|
" final_state_masses=dict.fromkeys(range(n), 0.13957),\n",
|
|
181
183
|
" backend=\"numpy\",\n",
|
|
@@ -216,7 +218,7 @@
|
|
|
216
218
|
"source": [
|
|
217
219
|
"### Usage\n",
|
|
218
220
|
"\n",
|
|
219
|
-
"The option is a keyword argument of {class}`.
|
|
221
|
+
"The option is a keyword argument of {class}`.PhaseSpaceGenerator`. The following example generates a sample of a three-body decay with both settings. The events differ, because the hit-and-miss step consumes the random numbers differently, but both samples are distributed uniformly over phase space: the events fill the kinematically allowed region of the Dalitz plot evenly."
|
|
220
222
|
]
|
|
221
223
|
},
|
|
222
224
|
{
|
|
@@ -227,8 +229,8 @@
|
|
|
227
229
|
"source": [
|
|
228
230
|
"is_mass = 3.0969\n",
|
|
229
231
|
"fs_masses = {0: 0.1350, 1: 0.1396, 2: 0.4937}\n",
|
|
230
|
-
"default_generator =
|
|
231
|
-
"adaptive_generator =
|
|
232
|
+
"default_generator = PhaseSpaceGenerator(is_mass, fs_masses)\n",
|
|
233
|
+
"adaptive_generator = PhaseSpaceGenerator(is_mass, fs_masses, adaptive_max_weight=True)"
|
|
232
234
|
]
|
|
233
235
|
},
|
|
234
236
|
{
|
|
@@ -241,12 +243,8 @@
|
|
|
241
243
|
"default_generator.show_progress = False\n",
|
|
242
244
|
"adaptive_generator.show_progress = False\n",
|
|
243
245
|
"samples = {\n",
|
|
244
|
-
" \"Default\": default_generator.generate(
|
|
245
|
-
"
|
|
246
|
-
" ),\n",
|
|
247
|
-
" \"adaptive_max_weight=True\": adaptive_generator.generate(\n",
|
|
248
|
-
" size, UniformRNG(seed=0, backend=\"tensorflow\")\n",
|
|
249
|
-
" ),\n",
|
|
246
|
+
" \"Default\": default_generator.generate(size, UniformRNG(seed=0)),\n",
|
|
247
|
+
" \"adaptive_max_weight=True\": adaptive_generator.generate(size, UniformRNG(seed=0)),\n",
|
|
250
248
|
"}"
|
|
251
249
|
]
|
|
252
250
|
},
|
|
@@ -333,9 +333,9 @@
|
|
|
333
333
|
"cell_type": "markdown",
|
|
334
334
|
"metadata": {},
|
|
335
335
|
"source": [
|
|
336
|
-
"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}`.
|
|
336
|
+
"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}`.PhaseSpaceGenerator` 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.\n",
|
|
337
337
|
"\n",
|
|
338
|
-
"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}`.
|
|
338
|
+
"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}`.PhaseSpaceGenerator.generate` method:"
|
|
339
339
|
]
|
|
340
340
|
},
|
|
341
341
|
{
|
|
@@ -366,10 +366,10 @@
|
|
|
366
366
|
},
|
|
367
367
|
"outputs": [],
|
|
368
368
|
"source": [
|
|
369
|
-
"from tensorwaves.data import
|
|
369
|
+
"from tensorwaves.data import PhaseSpaceGenerator, UniformRNG\n",
|
|
370
370
|
"\n",
|
|
371
|
-
"rng =
|
|
372
|
-
"phsp_generator =
|
|
371
|
+
"rng = UniformRNG(seed=0)\n",
|
|
372
|
+
"phsp_generator = PhaseSpaceGenerator(\n",
|
|
373
373
|
" initial_state_mass=reaction.initial_state[-1].mass,\n",
|
|
374
374
|
" final_state_masses={i: p.mass for i, p in reaction.final_state.items()},\n",
|
|
375
375
|
")\n",
|
|
@@ -407,7 +407,7 @@
|
|
|
407
407
|
},
|
|
408
408
|
"source": [
|
|
409
409
|
":::{tip}\n",
|
|
410
|
-
"For decays into many final state particles, `adaptive_max_weight=True` makes {class}`.
|
|
410
|
+
"For decays into many final state particles, `adaptive_max_weight=True` makes {class}`.PhaseSpaceGenerator` much faster. See {doc}`/amplitude-analysis/phase-space`.\n",
|
|
411
411
|
":::\n",
|
|
412
412
|
"\n",
|
|
413
413
|
"The resulting phase space sample is a {obj}`dict` of final state IDs to an {obj}`~numpy.array` of four-momenta. In the last step, we converted this sample in such a way that it is rendered as an understandable {class}`pandas.DataFrame`.\n",
|
|
@@ -456,7 +456,7 @@
|
|
|
456
456
|
"source": [
|
|
457
457
|
"'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",
|
|
458
458
|
"\n",
|
|
459
|
-
"An intensity-based sample is generated over a phase space sample using the {class}`.IntensityDistributionGenerator`. Its usage is similar to {class}`.
|
|
459
|
+
"An intensity-based sample is generated over a phase space sample using the {class}`.IntensityDistributionGenerator`. Its usage is similar to {class}`.PhaseSpaceGenerator`, 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",
|
|
460
460
|
"\n",
|
|
461
461
|
"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`:"
|
|
462
462
|
]
|
|
@@ -545,12 +545,9 @@
|
|
|
545
545
|
},
|
|
546
546
|
"outputs": [],
|
|
547
547
|
"source": [
|
|
548
|
-
"from tensorwaves.data import
|
|
549
|
-
" IntensityDistributionGenerator,\n",
|
|
550
|
-
" TFWeightedPhaseSpaceGenerator,\n",
|
|
551
|
-
")\n",
|
|
548
|
+
"from tensorwaves.data import IntensityDistributionGenerator, WeightedPhaseSpaceGenerator\n",
|
|
552
549
|
"\n",
|
|
553
|
-
"weighted_phsp_generator =
|
|
550
|
+
"weighted_phsp_generator = WeightedPhaseSpaceGenerator(\n",
|
|
554
551
|
" initial_state_mass=reaction.initial_state[-1].mass,\n",
|
|
555
552
|
" final_state_masses={i: p.mass for i, p in reaction.final_state.items()},\n",
|
|
556
553
|
")\n",
|
|
@@ -574,7 +571,7 @@
|
|
|
574
571
|
"As before, we use a {class}`.RealNumberGenerator` with a specific {attr}`~.RealNumberGenerator.seed` to ensure we get a **deterministic** data sample.\n",
|
|
575
572
|
"\n",
|
|
576
573
|
"> [!NOTE]\n",
|
|
577
|
-
"> Instead of constructing a {class}`.
|
|
574
|
+
"> Instead of constructing a {class}`.WeightedPhaseSpaceGenerator`, it's also possible to just reuse the **unweighted** {class}`.PhaseSpaceGenerator` that we constructed previously. This is, however, a bit slower, because the {class}`.PhaseSpaceGenerator` also uses a hit-and-miss strategy."
|
|
578
575
|
]
|
|
579
576
|
},
|
|
580
577
|
{
|
|
@@ -53,6 +53,10 @@ pip install tensorwaves[jax,scipy,tf]
|
|
|
53
53
|
pip install tensorwaves[all] # all runtime dependencies
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
+
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`.
|
|
57
|
+
|
|
58
|
+
TensorFlow does not support Python 3.14 and higher yet ([tensorflow/tensorflow#102890](https://github.com/tensorflow/tensorflow/issues/102890)), so on those versions the `tf` extra installs nothing and the TensorFlow backend is unavailable. Use NumPy, JAX, or Numba instead.
|
|
59
|
+
|
|
56
60
|
## Backend precision
|
|
57
61
|
|
|
58
62
|
TensorWaves uses 64-bit precision for JAX and TensorFlow by default. Configure 32-bit precision before creating backend arrays or TensorWaves functions with:
|
|
@@ -513,7 +513,7 @@
|
|
|
513
513
|
"metadata": {},
|
|
514
514
|
"source": [
|
|
515
515
|
"> [!NOTE]\n",
|
|
516
|
-
"> 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}`.
|
|
516
|
+
"> 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`, {doc}`/amplitude-analysis/phase-space`, and {ref}`amplitude-analysis:Step 2: Generate data`."
|
|
517
517
|
]
|
|
518
518
|
},
|
|
519
519
|
{
|
|
@@ -26,6 +26,8 @@ classifiers = [
|
|
|
26
26
|
"Programming Language :: Python :: 3.11",
|
|
27
27
|
"Programming Language :: Python :: 3.12",
|
|
28
28
|
"Programming Language :: Python :: 3.13",
|
|
29
|
+
"Programming Language :: Python :: 3.14",
|
|
30
|
+
"Programming Language :: Python :: 3.15",
|
|
29
31
|
"Topic :: Scientific/Engineering",
|
|
30
32
|
"Topic :: Scientific/Engineering :: Physics",
|
|
31
33
|
"Typing :: Typed",
|
|
@@ -54,10 +56,13 @@ Source = "https://github.com/ComPWA/tensorwaves"
|
|
|
54
56
|
[project.optional-dependencies]
|
|
55
57
|
jax = ["jax", "jaxlib"]
|
|
56
58
|
numba = ["numba"]
|
|
57
|
-
phsp = ["phasespace
|
|
59
|
+
phsp = ["phasespace>=2.0.0"]
|
|
58
60
|
pwa = ["ampform[viz]>=0.12.0", "tensorwaves[phsp]"]
|
|
59
61
|
scipy = ["scipy>=1"]
|
|
60
|
-
tf = [
|
|
62
|
+
tf = [
|
|
63
|
+
"tensorboard; python_version < '3.14'", # https://github.com/tensorflow/tensorflow/issues/102890
|
|
64
|
+
"tensorflow>=2.12; python_version < '3.14'",
|
|
65
|
+
]
|
|
61
66
|
|
|
62
67
|
[dependency-groups]
|
|
63
68
|
dev = [
|
|
@@ -101,13 +106,14 @@ notebooks = [
|
|
|
101
106
|
"pandas",
|
|
102
107
|
"qrules>=0.10.12", # qrules.io.asmermaid
|
|
103
108
|
"rich[jupyter]",
|
|
104
|
-
"tensorwaves[jax,pwa]",
|
|
109
|
+
"tensorwaves[jax,pwa,tf]",
|
|
105
110
|
]
|
|
106
111
|
style = [
|
|
107
112
|
{ include-group = "notebooks" },
|
|
108
113
|
{ include-group = "types" },
|
|
109
114
|
]
|
|
110
115
|
test = [
|
|
116
|
+
"phasespace>=2.0.0",
|
|
111
117
|
"pyarrow",
|
|
112
118
|
"pytest-benchmark",
|
|
113
119
|
"pytest-cov",
|
|
@@ -122,7 +128,7 @@ test-types = [
|
|
|
122
128
|
types = [
|
|
123
129
|
"numba",
|
|
124
130
|
"sphinx-api-relink",
|
|
125
|
-
"tensorwaves[jax,pwa]",
|
|
131
|
+
"tensorwaves[jax,pwa,tf]",
|
|
126
132
|
"types-PyYAML",
|
|
127
133
|
"types-requests",
|
|
128
134
|
"types-tensorflow",
|
|
@@ -150,7 +156,7 @@ macos-runner = "macos-latest"
|
|
|
150
156
|
ubuntu-runner = "ubuntu-26.04"
|
|
151
157
|
|
|
152
158
|
[tool.compwa.policy.python]
|
|
153
|
-
|
|
159
|
+
dev-python-version = "3.13" # https://github.com/tensorflow/tensorflow/issues/102890
|
|
154
160
|
type-checker = ["ty"]
|
|
155
161
|
|
|
156
162
|
[tool.coverage.report]
|
|
@@ -304,7 +310,7 @@ pytest ${paths} \
|
|
|
304
310
|
--durations=0 \
|
|
305
311
|
-k benchmark
|
|
306
312
|
"""
|
|
307
|
-
executor = { extra = ["jax", "numba", "pwa"], group = "test" }
|
|
313
|
+
executor = { extra = ["jax", "numba", "pwa", "tf"], group = "test" }
|
|
308
314
|
help = "Run benchmark tests and visualize performance"
|
|
309
315
|
|
|
310
316
|
[[tool.poe.groups.test.tasks.benchmark.args]]
|
|
@@ -321,7 +327,7 @@ pytest \
|
|
|
321
327
|
--cov-report=xml \
|
|
322
328
|
${paths}
|
|
323
329
|
"""
|
|
324
|
-
executor = { extra = ["jax", "numba", "pwa"], group = "test" }
|
|
330
|
+
executor = { extra = ["jax", "numba", "pwa", "tf"], group = "test" }
|
|
325
331
|
help = "Compute how much of the source code is covered by tests"
|
|
326
332
|
|
|
327
333
|
[[tool.poe.groups.test.tasks.cov.args]]
|
|
@@ -349,7 +355,7 @@ positional = true
|
|
|
349
355
|
|
|
350
356
|
[tool.poe.groups.test.tasks.test]
|
|
351
357
|
cmd = "pytest --benchmark-disable -m 'slow or not slow' ${paths}"
|
|
352
|
-
executor = { extra = ["jax", "numba", "pwa"], group = "test" }
|
|
358
|
+
executor = { extra = ["jax", "numba", "pwa", "tf"], group = "test" }
|
|
353
359
|
help = "Run all unit tests"
|
|
354
360
|
|
|
355
361
|
[[tool.poe.groups.test.tasks.test.args]]
|
|
@@ -364,6 +370,8 @@ sequence = [
|
|
|
364
370
|
"test-py311 ${paths}",
|
|
365
371
|
"test-py312 ${paths}",
|
|
366
372
|
"test-py313 ${paths}",
|
|
373
|
+
"test-py314 ${paths}",
|
|
374
|
+
"test-py315 ${paths}",
|
|
367
375
|
]
|
|
368
376
|
|
|
369
377
|
[[tool.poe.groups.test.tasks.test-all.args]]
|
|
@@ -384,6 +392,14 @@ ref = "test"
|
|
|
384
392
|
env = { UV_PYTHON = "3.13" }
|
|
385
393
|
ref = "test"
|
|
386
394
|
|
|
395
|
+
[tool.poe.groups.test.tasks.test-py314]
|
|
396
|
+
env = { UV_PYTHON = "3.14" }
|
|
397
|
+
ref = "test"
|
|
398
|
+
|
|
399
|
+
[tool.poe.groups.test.tasks.test-py315]
|
|
400
|
+
env = { UV_PYTHON = "3.15" }
|
|
401
|
+
ref = "test"
|
|
402
|
+
|
|
387
403
|
[tool.poe.tasks.all]
|
|
388
404
|
help = "Run all continuous integration (CI) tasks locally"
|
|
389
405
|
ignore_fail = "return_non_zero"
|
|
@@ -451,7 +467,10 @@ filterwarnings = [
|
|
|
451
467
|
"ignore:os\\.fork\\(\\) was called\\. os\\.fork\\(\\) is incompatible with multithreaded code, and JAX is multithreaded, so this will likely lead to a deadlock\\.:RuntimeWarning",
|
|
452
468
|
"ignore:unclosed .*:ResourceWarning",
|
|
453
469
|
]
|
|
454
|
-
markers = [
|
|
470
|
+
markers = [
|
|
471
|
+
"slow: marks tests as slow (select with '-m slow')",
|
|
472
|
+
"tensorflow: requires TensorFlow, skipped if it is not installed",
|
|
473
|
+
]
|
|
455
474
|
minversion = "9.0"
|
|
456
475
|
norecursedirs = [
|
|
457
476
|
".ipynb_checkpoints",
|
|
@@ -21,8 +21,8 @@ from ._data_sample import (
|
|
|
21
21
|
merge_events,
|
|
22
22
|
select_events,
|
|
23
23
|
)
|
|
24
|
-
from .phasespace import
|
|
25
|
-
from .phasespace import
|
|
24
|
+
from .phasespace import PhaseSpaceGenerator as PhaseSpaceGenerator
|
|
25
|
+
from .phasespace import WeightedPhaseSpaceGenerator as WeightedPhaseSpaceGenerator
|
|
26
26
|
from .rng import JAXUniformRNG as JAXUniformRNG
|
|
27
27
|
from .rng import NumpyUniformRNG as NumpyUniformRNG
|
|
28
28
|
from .rng import TFUniformRealNumberGenerator as TFUniformRealNumberGenerator
|
|
@@ -38,8 +38,8 @@ _BACKEND_EXTRAS: dict[str, tuple[str, str]] = {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
class
|
|
42
|
-
"""Implements a phase space generator
|
|
41
|
+
class PhaseSpaceGenerator(DataGenerator):
|
|
42
|
+
"""Implements a phase space generator on top of `phasespace <https://phasespace.readthedocs.io>`_.
|
|
43
43
|
|
|
44
44
|
:param initial_state_mass: Mass of the decaying state.
|
|
45
45
|
:param final_state_masses: Masses keyed by final-state ID.
|
|
@@ -54,7 +54,7 @@ class TFPhaseSpaceGenerator(DataGenerator):
|
|
|
54
54
|
`.IntensityDistributionGenerator`. The generated distribution stays the same,
|
|
55
55
|
but the events differ from those that are generated without this option for the
|
|
56
56
|
same seed. See :doc:`/amplitude-analysis/phase-space`.
|
|
57
|
-
:param backend: Computational backend
|
|
57
|
+
:param backend: Computational backend used by `WeightedPhaseSpaceGenerator`.
|
|
58
58
|
"""
|
|
59
59
|
|
|
60
60
|
def __init__(
|
|
@@ -64,9 +64,9 @@ class TFPhaseSpaceGenerator(DataGenerator):
|
|
|
64
64
|
bunch_size: int = 50_000,
|
|
65
65
|
*,
|
|
66
66
|
adaptive_max_weight: bool = False,
|
|
67
|
-
backend: Backend = "
|
|
67
|
+
backend: Backend = "numpy",
|
|
68
68
|
) -> None:
|
|
69
|
-
self.__phsp_generator =
|
|
69
|
+
self.__phsp_generator = WeightedPhaseSpaceGenerator(
|
|
70
70
|
initial_state_mass, final_state_masses, backend=backend
|
|
71
71
|
)
|
|
72
72
|
self.__bunch_size = bunch_size
|
|
@@ -126,18 +126,17 @@ class TFPhaseSpaceGenerator(DataGenerator):
|
|
|
126
126
|
return phsp
|
|
127
127
|
|
|
128
128
|
|
|
129
|
-
class
|
|
130
|
-
"""Implements a phase space generator **with weights**
|
|
129
|
+
class WeightedPhaseSpaceGenerator(DataGenerator):
|
|
130
|
+
"""Implements a phase space generator **with weights** on top of `phasespace <https://phasespace.readthedocs.io>`_.
|
|
131
131
|
|
|
132
132
|
The weights are provided in the returned `.DataSample` under the key ``"weights"``.
|
|
133
133
|
|
|
134
134
|
:param initial_state_mass: Mass of the decaying state.
|
|
135
135
|
:param final_state_masses: Masses keyed by final-state ID.
|
|
136
|
-
:param backend: Computational backend
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
backend provides a seed, so samples stay reproducible.
|
|
136
|
+
:param backend: Computational backend used to generate the sample. The
|
|
137
|
+
``tensorflow`` and ``jax`` backends require the ``tf`` and ``jax`` extras.
|
|
138
|
+
Generated arrays are always NumPy arrays. Any `.RealNumberGenerator` can be
|
|
139
|
+
used. A foreign stream supplies a seed, keeping samples reproducible.
|
|
141
140
|
|
|
142
141
|
.. seealso::
|
|
143
142
|
|
|
@@ -149,7 +148,7 @@ class TFWeightedPhaseSpaceGenerator(DataGenerator):
|
|
|
149
148
|
initial_state_mass: float,
|
|
150
149
|
final_state_masses: Mapping[int, float],
|
|
151
150
|
*,
|
|
152
|
-
backend: Backend = "
|
|
151
|
+
backend: Backend = "numpy",
|
|
153
152
|
) -> None:
|
|
154
153
|
if backend not in _BACKEND_EXTRAS:
|
|
155
154
|
msg = f'Backend must be one of {sorted(_BACKEND_EXTRAS)}, got "{backend}"'
|
|
@@ -22,8 +22,8 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
22
22
|
class UniformRNG(RealNumberGenerator):
|
|
23
23
|
"""Uniform real random number generator for a selectable computational backend.
|
|
24
24
|
|
|
25
|
-
Select the backend with the same string as `.
|
|
26
|
-
|
|
25
|
+
Select the backend with the same string as `.PhaseSpaceGenerator`, so that a script
|
|
26
|
+
can switch backends through one variable. The numbers are generated by
|
|
27
27
|
`NumpyUniformRNG`, `TFUniformRealNumberGenerator`, or `JAXUniformRNG`, which is
|
|
28
28
|
available as `implementation`.
|
|
29
29
|
"""
|
|
@@ -52,7 +52,7 @@ def get_backend_modules(backend: str | tuple | dict) -> str | tuple | dict:
|
|
|
52
52
|
|
|
53
53
|
return np, np.__dict__
|
|
54
54
|
# returning only np.__dict__ does not work well with conditionals
|
|
55
|
-
if backend
|
|
55
|
+
if backend == "tensorflow":
|
|
56
56
|
try:
|
|
57
57
|
tf = _initialize_tensorflow()
|
|
58
58
|
tnp = tf.experimental.numpy
|
|
@@ -284,7 +284,7 @@ def lambdify( # ruff:ignore[complex-structure, too-many-return-statements]
|
|
|
284
284
|
return jit_compile(jax_lambdify())
|
|
285
285
|
if backend == "numba":
|
|
286
286
|
return jit_compile(numba_lambdify())
|
|
287
|
-
if backend
|
|
287
|
+
if backend == "tensorflow":
|
|
288
288
|
return jit_compile(tensorflow_lambdify())
|
|
289
289
|
|
|
290
290
|
if isinstance(backend, tuple):
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '0.
|
|
22
|
-
__version_tuple__ = version_tuple = (0,
|
|
21
|
+
__version__ = version = '0.5.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 5, 0)
|
|
23
23
|
|
|
24
|
-
__commit_id__ = commit_id = '
|
|
24
|
+
__commit_id__ = commit_id = 'ge9175a493'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tensorwaves
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Python fitter package for multiple computational back-ends
|
|
5
5
|
Author-email: Common Partial Wave Analysis <compwa-admin@ep1.rub.de>
|
|
6
6
|
Maintainer-email: compwa-admin@ep1.rub.de
|
|
@@ -20,6 +20,8 @@ Classifier: Programming Language :: Python
|
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.11
|
|
21
21
|
Classifier: Programming Language :: Python :: 3.12
|
|
22
22
|
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
23
25
|
Classifier: Topic :: Scientific/Engineering
|
|
24
26
|
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
25
27
|
Classifier: Typing :: Typed
|
|
@@ -39,16 +41,15 @@ Requires-Dist: jaxlib; extra == "jax"
|
|
|
39
41
|
Provides-Extra: numba
|
|
40
42
|
Requires-Dist: numba; extra == "numba"
|
|
41
43
|
Provides-Extra: phsp
|
|
42
|
-
Requires-Dist: phasespace
|
|
43
|
-
Requires-Dist: tensorwaves[tf]; extra == "phsp"
|
|
44
|
+
Requires-Dist: phasespace>=2.0.0; extra == "phsp"
|
|
44
45
|
Provides-Extra: pwa
|
|
45
46
|
Requires-Dist: ampform[viz]>=0.12.0; extra == "pwa"
|
|
46
47
|
Requires-Dist: tensorwaves[phsp]; extra == "pwa"
|
|
47
48
|
Provides-Extra: scipy
|
|
48
49
|
Requires-Dist: scipy>=1; extra == "scipy"
|
|
49
50
|
Provides-Extra: tf
|
|
50
|
-
Requires-Dist: tensorboard; extra == "tf"
|
|
51
|
-
Requires-Dist: tensorflow>=2.12; extra == "tf"
|
|
51
|
+
Requires-Dist: tensorboard; python_version < "3.14" and extra == "tf"
|
|
52
|
+
Requires-Dist: tensorflow>=2.12; python_version < "3.14" and extra == "tf"
|
|
52
53
|
Dynamic: license-file
|
|
53
54
|
|
|
54
55
|
# TensorWaves
|
|
@@ -64,7 +65,7 @@ Dynamic: license-file
|
|
|
64
65
|
[](https://colab.research.google.com/github/ComPWA/tensorwaves/blob/stable)
|
|
65
66
|
[](https://github.dev/ComPWA/tensorwaves)
|
|
66
67
|
|
|
67
|
-
[](https://tensorwaves.readthedocs.io)
|
|
68
69
|
[](https://results.pre-commit.ci/latest/github/ComPWA/tensorwaves/main)
|
|
69
70
|
[](https://github.com/ComPWA/tensorwaves/actions/workflows/ci.yml)
|
|
70
71
|
[](https://codecov.io/gh/ComPWA/tensorwaves)
|