tensorwaves 0.4.18__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.
Files changed (112) hide show
  1. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/PKG-INFO +7 -6
  2. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/README.md +1 -1
  3. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/benchmarks/ampform.py +8 -6
  4. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/benchmarks/expression.py +2 -2
  5. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/docs/amplitude-analysis/analytic-continuation.ipynb +4 -8
  6. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/docs/amplitude-analysis/phase-space.ipynb +29 -46
  7. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/docs/amplitude-analysis.ipynb +10 -13
  8. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/docs/install.md +4 -0
  9. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/docs/usage/basics.ipynb +1 -1
  10. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/pyproject.toml +28 -9
  11. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/data/__init__.py +8 -6
  12. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/data/phasespace.py +15 -14
  13. tensorwaves-0.5.0/src/tensorwaves/data/rng.py +173 -0
  14. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/function/_backend.py +1 -1
  15. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/function/sympy/__init__.py +1 -1
  16. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/optimizer/__init__.py +2 -2
  17. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/version.py +3 -3
  18. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves.egg-info/PKG-INFO +7 -6
  19. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves.egg-info/requires.txt +3 -2
  20. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves.egg-info/scm_version.json +2 -2
  21. tensorwaves-0.5.0/tests/conftest.py +54 -0
  22. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/data/test_data.py +3 -2
  23. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/data/test_phasespace.py +73 -29
  24. tensorwaves-0.5.0/tests/data/test_rng.py +92 -0
  25. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/data/test_transform.py +1 -1
  26. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/function/test_ampform.py +3 -3
  27. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/function/test_backend.py +11 -4
  28. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/function/test_sympy.py +4 -4
  29. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/optimizer/test_fit_simple_model.py +1 -1
  30. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/test_config.py +1 -0
  31. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/test_estimator.py +1 -1
  32. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/uv.lock +79 -159
  33. tensorwaves-0.4.18/src/tensorwaves/data/rng.py +0 -88
  34. tensorwaves-0.4.18/tests/conftest.py +0 -20
  35. tensorwaves-0.4.18/tests/data/test_rng.py +0 -44
  36. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.binder/apt.txt +0 -0
  37. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.binder/postBuild +0 -0
  38. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.binder/runtime.txt +0 -0
  39. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.cspell.json +0 -0
  40. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.editorconfig +0 -0
  41. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.envrc +0 -0
  42. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.gitattributes +0 -0
  43. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.github/dependabot.yml +0 -0
  44. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.github/release-drafter.yml +0 -0
  45. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.github/workflows/benchmark.yml +0 -0
  46. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.github/workflows/cd.yml +0 -0
  47. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.github/workflows/ci.yml +0 -0
  48. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.github/workflows/clean-caches.yml +0 -0
  49. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.github/workflows/lock.yml +0 -0
  50. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.github/workflows/pr-linting.yml +0 -0
  51. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.github/workflows/redirect-gh-pages.yml +0 -0
  52. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.github/workflows/release-drafter.yml +0 -0
  53. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.gitignore +0 -0
  54. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.pre-commit-config.yaml +0 -0
  55. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.prettierignore +0 -0
  56. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.python-version +0 -0
  57. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.readthedocs.yml +0 -0
  58. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.vscode/extensions.json +0 -0
  59. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.vscode/launch.json +0 -0
  60. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/.vscode/settings.json +0 -0
  61. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/CITATION.cff +0 -0
  62. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/CONTRIBUTING.md +0 -0
  63. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/LICENSE +0 -0
  64. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/benchmarks/__init__.py +0 -0
  65. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/benchmarks/conftest.py +0 -0
  66. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/benchmarks/precision.py +0 -0
  67. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/benchmarks/unbinned_nll.py +0 -0
  68. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/codecov.yml +0 -0
  69. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/docs/.gitignore +0 -0
  70. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/docs/_static/favicon.ico +0 -0
  71. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/docs/_static/linebreaks-api.css +0 -0
  72. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/docs/_static/mermaid.css +0 -0
  73. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/docs/conf.py +0 -0
  74. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/docs/index.md +0 -0
  75. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/docs/tensorflow.txt +0 -0
  76. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/docs/usage/binned-fit.ipynb +0 -0
  77. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/docs/usage/caching.ipynb +0 -0
  78. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/docs/usage/chi-squared.ipynb +0 -0
  79. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/docs/usage/faster-lambdify.ipynb +0 -0
  80. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/docs/usage/unbinned-fit.ipynb +0 -0
  81. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/docs/usage.ipynb +0 -0
  82. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/setup.cfg +0 -0
  83. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/__init__.py +0 -0
  84. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/config.py +0 -0
  85. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/data/_attrs.py +0 -0
  86. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/data/_data_sample.py +0 -0
  87. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/data/transform.py +0 -0
  88. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/estimator.py +0 -0
  89. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/function/__init__.py +0 -0
  90. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/function/sympy/_printer.py +0 -0
  91. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/interface.py +0 -0
  92. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/optimizer/callbacks.py +0 -0
  93. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/optimizer/minuit.py +0 -0
  94. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/optimizer/parameter.py +0 -0
  95. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/optimizer/scipy.py +0 -0
  96. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves/py.typed +0 -0
  97. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves.egg-info/SOURCES.txt +0 -0
  98. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves.egg-info/dependency_links.txt +0 -0
  99. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves.egg-info/scm_file_list.json +0 -0
  100. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/src/tensorwaves.egg-info/top_level.txt +0 -0
  101. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/__init__.py +0 -0
  102. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/data/__init__.py +0 -0
  103. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/function/__init__.py +0 -0
  104. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/function/test_function.py +0 -0
  105. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/optimizer/__init__.py +0 -0
  106. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/optimizer/test_callbacks.py +0 -0
  107. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/optimizer/test_gradient.py +0 -0
  108. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/optimizer/test_minuit.py +0 -0
  109. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/optimizer/test_parameter.py +0 -0
  110. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/optimizer/test_scipy.py +0 -0
  111. {tensorwaves-0.4.18 → tensorwaves-0.5.0}/tests/output/.gitignore +0 -0
  112. {tensorwaves-0.4.18 → 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.4.18
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[tf]>=1.11.0; extra == "phsp"
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
  [![Google Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ComPWA/tensorwaves/blob/stable)
65
66
  [![Open in Visual Studio Code](https://img.shields.io/badge/vscode-open-blue?logo=visualstudiocode)](https://github.dev/ComPWA/tensorwaves)
66
67
 
67
- [![Documentation build status](https://readthedocs.org/projects/tensorwaves/badge/?version=latest)](https://tensorwaves.readthedocs.io)
68
+ [![Documentation build status](https://img.shields.io/readthedocs/tensorwaves/latest)](https://tensorwaves.readthedocs.io)
68
69
  [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/ComPWA/tensorwaves/main.svg)](https://results.pre-commit.ci/latest/github/ComPWA/tensorwaves/main)
69
70
  [![CI](https://github.com/ComPWA/tensorwaves/actions/workflows/ci.yml/badge.svg)](https://github.com/ComPWA/tensorwaves/actions/workflows/ci.yml)
70
71
  [![Test coverage](https://codecov.io/gh/ComPWA/tensorwaves/branch/main/graph/badge.svg)](https://codecov.io/gh/ComPWA/tensorwaves)
@@ -11,7 +11,7 @@
11
11
  [![Google Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ComPWA/tensorwaves/blob/stable)
12
12
  [![Open in Visual Studio Code](https://img.shields.io/badge/vscode-open-blue?logo=visualstudiocode)](https://github.dev/ComPWA/tensorwaves)
13
13
 
14
- [![Documentation build status](https://readthedocs.org/projects/tensorwaves/badge/?version=latest)](https://tensorwaves.readthedocs.io)
14
+ [![Documentation build status](https://img.shields.io/readthedocs/tensorwaves/latest)](https://tensorwaves.readthedocs.io)
15
15
  [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/ComPWA/tensorwaves/main.svg)](https://results.pre-commit.ci/latest/github/ComPWA/tensorwaves/main)
16
16
  [![CI](https://github.com/ComPWA/tensorwaves/actions/workflows/ci.yml/badge.svg)](https://github.com/ComPWA/tensorwaves/actions/workflows/ci.yml)
17
17
  [![Test coverage](https://codecov.io/gh/ComPWA/tensorwaves/branch/main/graph/badge.svg)](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
- TFWeightedPhaseSpaceGenerator,
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 = TFPhaseSpaceGenerator(initial_state_mass, final_state_masses)
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 = TFWeightedPhaseSpaceGenerator(
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", "tf"])
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", "tf"])
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", "tf"])
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(
@@ -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 (\n",
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 = TFUniformRealNumberGenerator(seed=0)\n",
171
- "phsp_generator = TFPhaseSpaceGenerator(\n",
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.16"
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}`.TFPhaseSpaceGenerator` produces such samples with [`phasespace`](https://phasespace.readthedocs.io), which can run on TensorFlow, NumPy, or JAX. `phasespace` generates *weighted* events, so {class}`.TFPhaseSpaceGenerator` 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}`.TFWeightedPhaseSpaceGenerator` 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."
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
  {
@@ -51,7 +51,7 @@
51
51
  "source": [
52
52
  "## Backends\n",
53
53
  "\n",
54
- "The backend is selected with the `backend` argument of the generator. All backends return a {obj}`.DataSample` of NumPy arrays with the same structure, so they can be swapped without changing the rest of an analysis."
54
+ "The backend is selected with the `backend` argument of the generator. All backends return a {obj}`.DataSample` of NumPy arrays with the same structure, so they can be swapped without changing the rest of an analysis. A {class}`.UniformRNG` takes the same `backend` argument, so one string selects both the generator and a matching random number generator."
55
55
  ]
56
56
  },
57
57
  {
@@ -60,32 +60,17 @@
60
60
  "metadata": {},
61
61
  "outputs": [],
62
62
  "source": [
63
- "from tensorwaves.data import (\n",
64
- " NumpyUniformRNG,\n",
65
- " TFPhaseSpaceGenerator,\n",
66
- " TFUniformRealNumberGenerator,\n",
67
- ")\n",
63
+ "from tensorwaves.data import PhaseSpaceGenerator, UniformRNG\n",
68
64
  "\n",
69
- "initial_state_mass = 3.0969\n",
70
- "final_state_masses = {0: 0.1350, 1: 0.1396, 2: 0.4937}\n",
71
- "generators = {\n",
72
- " \"numpy\": (\n",
73
- " TFPhaseSpaceGenerator(initial_state_mass, final_state_masses, backend=\"numpy\"),\n",
74
- " NumpyUniformRNG(seed=0),\n",
75
- " ),\n",
76
- " \"tensorflow\": (\n",
77
- " TFPhaseSpaceGenerator(\n",
78
- " initial_state_mass, final_state_masses, backend=\"tensorflow\"\n",
79
- " ),\n",
80
- " TFUniformRealNumberGenerator(seed=0),\n",
81
- " ),\n",
82
- " \"jax\": (\n",
83
- " TFPhaseSpaceGenerator(initial_state_mass, final_state_masses, backend=\"jax\"),\n",
84
- " NumpyUniformRNG(seed=0),\n",
85
- " ),\n",
86
- "}\n",
87
- "for generator, _ in generators.values():\n",
88
- " generator.show_progress = False"
65
+ "generators = {}\n",
66
+ "for backend in [\"numpy\", \"tensorflow\", \"jax\"]:\n",
67
+ " generator = PhaseSpaceGenerator(\n",
68
+ " initial_state_mass=3.0969,\n",
69
+ " final_state_masses={0: 0.1350, 1: 0.1396, 2: 0.4937},\n",
70
+ " backend=backend,\n",
71
+ " )\n",
72
+ " generator.show_progress = False\n",
73
+ " generators[backend] = (generator, UniformRNG(seed=0, backend=backend))"
89
74
  ]
90
75
  },
91
76
  {
@@ -94,16 +79,18 @@
94
79
  "source": [
95
80
  "| `backend` | Extra | Use of the {class}`.RealNumberGenerator` |\n",
96
81
  "| --- | --- | --- |\n",
97
- "| `\"tensorflow\"` (default) | `phsp` | {class}`.TFUniformRealNumberGenerator` is used directly, any other type only provides a seed |\n",
98
- "| `\"numpy\"` | `phsp` | {class}`.NumpyUniformRNG` is used directly, any other type only provides a seed |\n",
99
- "| `\"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`."
100
87
  ]
101
88
  },
102
89
  {
103
90
  "cell_type": "markdown",
104
91
  "metadata": {},
105
92
  "source": [
106
- "Every backend is used through the same {meth}`~.TFPhaseSpaceGenerator.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."
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."
107
94
  ]
108
95
  },
109
96
  {
@@ -143,7 +130,7 @@
143
130
  "cell_type": "markdown",
144
131
  "metadata": {},
145
132
  "source": [
146
- "TensorFlow is the default, because it reproduces the samples of earlier TensorWaves versions, when combined with a {class}`.TFUniformRealNumberGenerator`. NumPy needs no compilation, so it is the fastest choice for a few small samples. 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. 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",
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",
147
134
  "\n",
148
135
  "There are two things to keep in mind:\n",
149
136
  "\n",
@@ -185,17 +172,17 @@
185
172
  },
186
173
  "outputs": [],
187
174
  "source": [
188
- "from tensorwaves.data import TFWeightedPhaseSpaceGenerator\n",
175
+ "from tensorwaves.data import WeightedPhaseSpaceGenerator\n",
189
176
  "\n",
190
177
  "n_particles = list(range(3, 9))\n",
191
178
  "weights = {}\n",
192
179
  "for n in n_particles:\n",
193
- " weighted_generator = TFWeightedPhaseSpaceGenerator(\n",
180
+ " weighted_generator = WeightedPhaseSpaceGenerator(\n",
194
181
  " initial_state_mass=5.0,\n",
195
182
  " final_state_masses=dict.fromkeys(range(n), 0.13957),\n",
196
183
  " backend=\"numpy\",\n",
197
184
  " )\n",
198
- " rng = NumpyUniformRNG(seed=0)\n",
185
+ " rng = UniformRNG(seed=0, backend=\"numpy\")\n",
199
186
  " weights[n] = weighted_generator.generate(100_000, rng)[\"weights\"]\n",
200
187
  "\n",
201
188
  "fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(10, 3.8), layout=\"constrained\")\n",
@@ -231,7 +218,7 @@
231
218
  "source": [
232
219
  "### Usage\n",
233
220
  "\n",
234
- "The option is a keyword argument of {class}`.TFPhaseSpaceGenerator`. 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."
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."
235
222
  ]
236
223
  },
237
224
  {
@@ -240,12 +227,10 @@
240
227
  "metadata": {},
241
228
  "outputs": [],
242
229
  "source": [
243
- "initial_state_mass = 3.0969\n",
244
- "final_state_masses = {0: 0.1350, 1: 0.1396, 2: 0.4937}\n",
245
- "default_generator = TFPhaseSpaceGenerator(initial_state_mass, final_state_masses)\n",
246
- "adaptive_generator = TFPhaseSpaceGenerator(\n",
247
- " initial_state_mass, final_state_masses, adaptive_max_weight=True\n",
248
- ")"
230
+ "is_mass = 3.0969\n",
231
+ "fs_masses = {0: 0.1350, 1: 0.1396, 2: 0.4937}\n",
232
+ "default_generator = PhaseSpaceGenerator(is_mass, fs_masses)\n",
233
+ "adaptive_generator = PhaseSpaceGenerator(is_mass, fs_masses, adaptive_max_weight=True)"
249
234
  ]
250
235
  },
251
236
  {
@@ -258,10 +243,8 @@
258
243
  "default_generator.show_progress = False\n",
259
244
  "adaptive_generator.show_progress = False\n",
260
245
  "samples = {\n",
261
- " \"Default\": default_generator.generate(size, TFUniformRealNumberGenerator(seed=0)),\n",
262
- " \"adaptive_max_weight=True\": adaptive_generator.generate(\n",
263
- " size, TFUniformRealNumberGenerator(seed=0)\n",
264
- " ),\n",
246
+ " \"Default\": default_generator.generate(size, UniformRNG(seed=0)),\n",
247
+ " \"adaptive_max_weight=True\": adaptive_generator.generate(size, UniformRNG(seed=0)),\n",
265
248
  "}"
266
249
  ]
267
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}`.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.\n",
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}`.TFPhaseSpaceGenerator.generate` method:"
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 TFPhaseSpaceGenerator, TFUniformRealNumberGenerator\n",
369
+ "from tensorwaves.data import PhaseSpaceGenerator, UniformRNG\n",
370
370
  "\n",
371
- "rng = TFUniformRealNumberGenerator(seed=0)\n",
372
- "phsp_generator = TFPhaseSpaceGenerator(\n",
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}`.TFPhaseSpaceGenerator` much faster. See {doc}`/amplitude-analysis/phase-space`.\n",
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}`.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",
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 (\n",
549
- " IntensityDistributionGenerator,\n",
550
- " TFWeightedPhaseSpaceGenerator,\n",
551
- ")\n",
548
+ "from tensorwaves.data import IntensityDistributionGenerator, WeightedPhaseSpaceGenerator\n",
552
549
  "\n",
553
- "weighted_phsp_generator = TFWeightedPhaseSpaceGenerator(\n",
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}`.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."
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}`.TFPhaseSpaceGenerator`, {doc}`/amplitude-analysis/phase-space`, and {ref}`amplitude-analysis:Step 2: Generate data`."
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[tf]>=1.11.0", "tensorwaves[tf]"]
59
+ phsp = ["phasespace>=2.0.0"]
58
60
  pwa = ["ampform[viz]>=0.12.0", "tensorwaves[phsp]"]
59
61
  scipy = ["scipy>=1"]
60
- tf = ["tensorboard", "tensorflow>=2.12"]
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
- excluded-python-versions = ["3.14", "3.15"]
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 = ["slow: marks tests as slow (select with '-m slow')"]
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,12 +21,14 @@ from ._data_sample import (
21
21
  merge_events,
22
22
  select_events,
23
23
  )
24
- from .phasespace import (
25
- TFPhaseSpaceGenerator, # ruff:ignore[unused-import]
26
- TFWeightedPhaseSpaceGenerator, # ruff:ignore[unused-import]
27
- )
28
- from .rng import NumpyUniformRNG, TFUniformRealNumberGenerator # ruff:ignore[unused-import]
29
- from .transform import IdentityTransformer, SympyDataTransformer # ruff:ignore[unused-import]
24
+ from .phasespace import PhaseSpaceGenerator as PhaseSpaceGenerator
25
+ from .phasespace import WeightedPhaseSpaceGenerator as WeightedPhaseSpaceGenerator
26
+ from .rng import JAXUniformRNG as JAXUniformRNG
27
+ from .rng import NumpyUniformRNG as NumpyUniformRNG
28
+ from .rng import TFUniformRealNumberGenerator as TFUniformRealNumberGenerator
29
+ from .rng import UniformRNG as UniformRNG
30
+ from .transform import IdentityTransformer as IdentityTransformer
31
+ from .transform import SympyDataTransformer as SympyDataTransformer
30
32
 
31
33
  _LOGGER = logging.getLogger(__name__)
32
34
 
@@ -17,7 +17,7 @@ from ._data_sample import (
17
17
  merge_events,
18
18
  select_events,
19
19
  )
20
- from .rng import NumpyUniformRNG, TFUniformRealNumberGenerator
20
+ from .rng import NumpyUniformRNG, TFUniformRealNumberGenerator, UniformRNG
21
21
 
22
22
  if TYPE_CHECKING:
23
23
  from collections.abc import Mapping
@@ -38,8 +38,8 @@ _BACKEND_EXTRAS: dict[str, tuple[str, str]] = {
38
38
  }
39
39
 
40
40
 
41
- class TFPhaseSpaceGenerator(DataGenerator):
42
- """Implements a phase space generator using tensorflow.
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 of `TFWeightedPhaseSpaceGenerator`.
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 = "tensorflow",
67
+ backend: Backend = "numpy",
68
68
  ) -> None:
69
- self.__phsp_generator = TFWeightedPhaseSpaceGenerator(
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 TFWeightedPhaseSpaceGenerator(DataGenerator):
130
- """Implements a phase space generator **with weights** using tensorflow.
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 that `phasespace
137
- <https://github.com/zfit/phasespace>`_ uses to generate the sample. The
138
- ``"jax"`` backend also requires the ``jax`` extra. The generated arrays are
139
- always NumPy arrays. A `.RealNumberGenerator` that does not belong to the
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 = "tensorflow",
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}"'
@@ -206,6 +205,8 @@ def _activate_backend(backend: Backend) -> None:
206
205
  def _get_seed(
207
206
  rng: RealNumberGenerator, backend: Backend
208
207
  ) -> int | np.random.Generator | tf.random.Generator:
208
+ if isinstance(rng, UniformRNG):
209
+ rng = rng.implementation
209
210
  if backend == "numpy" and isinstance(rng, NumpyUniformRNG):
210
211
  return rng.generator
211
212
  if backend == "tensorflow" and isinstance(rng, TFUniformRealNumberGenerator):