Skip to content

Commit bff8a03

Browse files
authored
build!: replace expertsystem with ampform (#262)
1 parent 732e4ab commit bff8a03

38 files changed

+153
-124
lines changed

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"json.schemas": [
4747
{
4848
"fileMatch": ["*particle*.json"],
49-
"url": "https://raw.githubusercontent.com/ComPWA/expertsystem/0.7.2/src/expertsystem/particle/validation.json"
49+
"url": "https://raw.githubusercontent.com/ComPWA/qrules/0.8.0a1/src/qrules/particle-validation.json"
5050
}
5151
],
5252
"python.analysis.autoImportCompletions": false,
@@ -75,7 +75,7 @@
7575
"telemetry.enableCrashReporter": false,
7676
"telemetry.enableTelemetry": false,
7777
"yaml.schemas": {
78-
"https://raw.githubusercontent.com/ComPWA/expertsystem/0.7.2/src/expertsystem/particle/validation.json": [
78+
"https://raw.githubusercontent.com/ComPWA/qrules/0.8.0a1/src/qrules/particle-validation.json": [
7979
"*particle.y*ml"
8080
]
8181
}

cspell.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"determinator",
6060
"determinators",
6161
"docstrings",
62-
"expertsystem",
6362
"flatté",
6463
"functors",
6564
"gaussians",
@@ -107,6 +106,7 @@
107106
"zfit"
108107
],
109108
"ignoreWords": [
109+
"ampform",
110110
"arange",
111111
"asdot",
112112
"atfi",
@@ -180,6 +180,7 @@
180180
"pyproject",
181181
"pyright",
182182
"pytestconfig",
183+
"qrules",
183184
"rightarrow",
184185
"rtfd",
185186
"scipy",

docs/conf.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import os
1111
import shutil
1212
import subprocess
13+
import sys
1314

1415
from pkg_resources import get_distribution
1516

@@ -133,11 +134,23 @@
133134
]
134135

135136
# Intersphinx settings
137+
python_version = f"{sys.version_info.major}.{sys.version_info.minor}"
138+
pinned_requirements_path = f"../reqs/{python_version}/requirements-dev.txt"
139+
with open(pinned_requirements_path) as stream:
140+
requirements_str = stream.read()
141+
reqs = dict()
142+
for line in requirements_str.split("\n"):
143+
line = line.split("#")[0] # remove comments
144+
line = line.strip()
145+
if not line:
146+
continue
147+
package, version = tuple(line.split("=="))
148+
package = package.strip()
149+
version = version.strip()
150+
reqs[package] = version
151+
136152
intersphinx_mapping = {
137-
"expertsystem": (
138-
"https://pwa.readthedocs.io/projects/expertsystem/en/0.7.2",
139-
None,
140-
),
153+
"ampform": (f"https://ampform.readthedocs.io/en/{reqs['ampform']}/", None),
141154
"iminuit": ("https://iminuit.readthedocs.io/en/stable", None),
142155
"jax": ("https://jax.readthedocs.io/en/stable", None),
143156
"matplotlib": ("https://matplotlib.org", None),
@@ -147,6 +160,7 @@
147160
"pwa": ("https://pwa.readthedocs.io", None),
148161
"pycompwa": ("https://compwa.github.io", None),
149162
"python": ("https://docs.python.org/3", None),
163+
"qrules": (f"https://qrules.readthedocs.io/en/{reqs['qrules']}/", None),
150164
"scipy": ("https://docs.scipy.org/doc/scipy/reference/", None),
151165
"sympy": ("https://docs.sympy.org/latest", None),
152166
"tensorflow": (

docs/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Develop <https://pwa.readthedocs.io/develop.html>
6060
caption: Related projects
6161
hidden:
6262
---
63-
Expert System <http://expertsystem.readthedocs.io>
63+
AmpForm <http://ampform.readthedocs.io>
64+
QRules <http://qrules.readthedocs.io>
6465
PWA Pages <http://pwa.readthedocs.io>
6566
```

docs/usage.ipynb

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"source": [
4848
"TensorWaves is a package for fitting general mathematical expressions to data distributions. The fundamentals behind the package are illustrated in {doc}`/usage/basics`.\n",
4949
"\n",
50-
"While general in design, the package is intended for doing {doc}`Partial Wave Analysis <pwa:index>`. First, the {mod}`expertsystem` determines which transitions are allowed from some initial state to a final state. It then formulates those transitions mathematically as an {ref}`amplitude model <usage:Construct a model>`. TensorWaves can then {meth}`~.Model.lambdify` this expression to some computational backend. Finally, TensorWaves {ref}`'fits' <usage:Optimize the model>` this model to some data sample. Optionally, a data sample can be {ref}`generated <usage:Generate data sample>` from the model.\n",
50+
"While general in design, the package is intended for doing {doc}`Partial Wave Analysis <pwa:index>`. First, the {mod}`ampform` package determines which transitions are allowed from some initial state to a final state. It then formulates those transitions mathematically as an {ref}`amplitude model <usage:Construct a model>`. TensorWaves can then {meth}`~.Model.lambdify` this expression to some computational backend. Finally, TensorWaves {ref}`'fits' <usage:Optimize the model>` this model to some data sample. Optionally, a data sample can be {ref}`generated <usage:Generate data sample>` from the model.\n",
5151
"\n",
5252
"This page shows a brief overview of the complete workflow. More info about each step can be found under {ref}`usage:Step-by-step workflow`."
5353
]
@@ -81,22 +81,18 @@
8181
"cell_type": "code",
8282
"execution_count": null,
8383
"metadata": {
84-
"jupyter": {
85-
"source_hidden": true
86-
},
8784
"tags": [
8885
"hide-cell"
8986
]
9087
},
9188
"outputs": [],
9289
"source": [
93-
"import expertsystem as es\n",
90+
"import ampform\n",
9491
"import graphviz\n",
9592
"import matplotlib.pyplot as plt\n",
9693
"import pandas as pd\n",
97-
"from expertsystem.amplitude.dynamics.builder import (\n",
98-
" create_relativistic_breit_wigner_with_ff,\n",
99-
")\n",
94+
"import qrules as q\n",
95+
"from ampform.dynamics.builder import create_relativistic_breit_wigner_with_ff\n",
10096
"from tensorwaves.data import generate_data, generate_phsp\n",
10197
"from tensorwaves.data.transform import HelicityTransformer\n",
10298
"from tensorwaves.estimator import UnbinnedNLL\n",
@@ -111,14 +107,14 @@
111107
"metadata": {},
112108
"outputs": [],
113109
"source": [
114-
"result = es.generate_transitions(\n",
110+
"result = q.generate_transitions(\n",
115111
" initial_state=(\"J/psi(1S)\", [-1, +1]),\n",
116112
" final_state=[\"gamma\", \"pi0\", \"pi0\"],\n",
117113
" allowed_intermediate_particles=[\"f(0)\"],\n",
118114
" allowed_interaction_types=[\"strong\", \"EM\"],\n",
119115
" formalism_type=\"canonical-helicity\",\n",
120116
")\n",
121-
"dot = es.io.asdot(result, collapse_graphs=True)\n",
117+
"dot = q.io.asdot(result, collapse_graphs=True)\n",
122118
"graphviz.Source(dot)"
123119
]
124120
},
@@ -128,7 +124,7 @@
128124
"metadata": {},
129125
"outputs": [],
130126
"source": [
131-
"model_builder = es.amplitude.get_builder(result)\n",
127+
"model_builder = ampform.get_builder(result)\n",
132128
"for name in result.get_intermediate_particles().names:\n",
133129
" model_builder.set_dynamics(name, create_relativistic_breit_wigner_with_ff)\n",
134130
"model = model_builder.generate()"

docs/usage/basics.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"cell_type": "markdown",
4444
"metadata": {},
4545
"source": [
46-
"The {doc}`/usage` page illustrates how to use {mod}`tensorwaves` in combination with the {mod}`expertsystem`. At core, however, {mod}`tensorwaves` is a package that can 'fit' arbitrary models to a data set using different backends, as well as generate toy data samples.\n",
46+
"The {doc}`/usage` page illustrates how to use {mod}`tensorwaves` in combination with {mod}`ampform`. At core, however, {mod}`tensorwaves` is a package that can 'fit' arbitrary models to a data set using different backends, as well as generate toy data samples.\n",
4747
"\n",
4848
"These pages illustrate what's going on behind the scenes with some simple 1-dimensional and 2-dimensional models. Since we don't have a data sample to fit a model to, we follow the the same procedure as in the {doc}`/usage` page:\n",
4949
"\n",

docs/usage/step1.ipynb

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
"cell_type": "markdown",
4444
"metadata": {},
4545
"source": [
46-
"TensorWaves requires you to first formulate a mathematical {class}`.Model` that you want to fit to your data set. When this model is an amplitude model, it is most convenient to construct it with the {mod}`expertsystem`.\n",
46+
"TensorWaves requires you to first formulate a mathematical {class}`.Model` that you want to fit to your data set. When this model is an amplitude model, it is most convenient to construct it with {mod}`ampform`.\n",
4747
"\n",
48-
"This notebook briefly illustrates how to create such an amplitude model with the {mod}`expertsystem` and how to write it to a recipe file that can be understood by {mod}`tensorwaves`. For more control, have a look at {doc}`the usage guides of the PWA Expert System <expertsystem:usage>`."
48+
"This notebook briefly illustrates how to create such an amplitude model with {mod}`ampform` and how to write it to a recipe file that can be understood by {mod}`tensorwaves`. For more control, have a look at {doc}`the usage guides of AmpForm <ampform:usage>`."
4949
]
5050
},
5151
{
@@ -63,7 +63,7 @@
6363
"---\n",
6464
"class: dropdown\n",
6565
"---\n",
66-
"As {doc}`step3` serves to illustrate usage only, we make the amplitude model here a bit simpler by not allowing $\\omega$ resonances (which are narrow and therefore hard to fit). For this reason, we can also limit the {class}`~expertsystem.reaction.default_settings.InteractionTypes` to {attr}`~expertsystem.reaction.default_settings.InteractionTypes.STRONG`.\n",
66+
"As {doc}`step3` serves to illustrate usage only, we make the amplitude model here a bit simpler by not allowing $\\omega$ resonances (which are narrow and therefore hard to fit). For this reason, we can also limit the {class}`~qrules.default_settings.InteractionTypes` to {attr}`~qrules.default_settings.InteractionTypes.STRONG`.\n",
6767
"```"
6868
]
6969
},
@@ -73,9 +73,9 @@
7373
"metadata": {},
7474
"outputs": [],
7575
"source": [
76-
"import expertsystem as es\n",
76+
"import qrules as q\n",
7777
"\n",
78-
"result = es.generate_transitions(\n",
78+
"result = q.generate_transitions(\n",
7979
" initial_state=(\"J/psi(1S)\", [-1, +1]),\n",
8080
" final_state=[\"gamma\", \"pi0\", \"pi0\"],\n",
8181
" allowed_intermediate_particles=[\"f(0)\"],\n",
@@ -87,7 +87,7 @@
8787
"cell_type": "markdown",
8888
"metadata": {},
8989
"source": [
90-
"As a small goodie, you can use [`graphviz`](https://pypi.org/project/graphviz) to {doc}`visualize <expertsystem:usage/visualize>` the generated graphs:"
90+
"As a small goodie, you can use [`graphviz`](https://pypi.org/project/graphviz) to {doc}`visualize <qrules:usage/visualize>` the generated graphs:"
9191
]
9292
},
9393
{
@@ -98,15 +98,15 @@
9898
"source": [
9999
"from graphviz import Source\n",
100100
"\n",
101-
"dot = es.io.asdot(result, collapse_graphs=True)\n",
101+
"dot = q.io.asdot(result, collapse_graphs=True)\n",
102102
"Source(dot)"
103103
]
104104
},
105105
{
106106
"cell_type": "markdown",
107107
"metadata": {},
108108
"source": [
109-
"Next we convert the {attr}`~expertsystem.reaction.Result.transitions` into an amplitude model (here: {class}`~expertsystem.amplitude.helicity.HelicityModel`). This can be done with {func}`~expertsystem.amplitude.get_builder` and {meth}`~expertsystem.amplitude.helicity.HelicityAmplitudeBuilder.generate`."
109+
"Next we convert the {attr}`~qrules.transition.Result.transitions` into an amplitude model (here: {class}`~ampform.helicity.HelicityModel`). This can be done with {func}`~ampform.get_builder` and {meth}`~ampform.helicity.HelicityAmplitudeBuilder.generate`."
110110
]
111111
},
112112
{
@@ -115,7 +115,9 @@
115115
"metadata": {},
116116
"outputs": [],
117117
"source": [
118-
"model_builder = es.amplitude.get_builder(result)\n",
118+
"import ampform\n",
119+
"\n",
120+
"model_builder = ampform.get_builder(result)\n",
119121
"model = model_builder.generate()\n",
120122
"display(*model.parameter_defaults)"
121123
]
@@ -128,7 +130,7 @@
128130
"1. The coefficients for the different amplitudes are **complex** valued.\n",
129131
"2. By default there is no dynamics in the model, so it still has to be specified.\n",
130132
"\n",
131-
"We choose to use {func}`~expertsystem.amplitude.dynamics.lineshape.relativistic_breit_wigner_with_ff` as the lineshape for all resonances and use a {class}`~expertsystem.amplitude.dynamics.lineshape.BlattWeisskopf` form factor factor (no dynamics) for the production decay. The {meth}`~expertsystem.amplitude.helicity.HelicityAmplitudeBuilder.set_dynamics` is a convenience interface for replacing the dynamics for intermediate states."
133+
"We choose to use {func}`~ampform.dynamics.lineshape.relativistic_breit_wigner_with_ff` as the lineshape for all resonances and use a {class}`~ampform.dynamics.lineshape.BlattWeisskopf` form factor factor (no dynamics) for the production decay. The {meth}`~ampform.helicity.HelicityAmplitudeBuilder.set_dynamics` is a convenience interface for replacing the dynamics for intermediate states."
132134
]
133135
},
134136
{
@@ -137,7 +139,7 @@
137139
"metadata": {},
138140
"outputs": [],
139141
"source": [
140-
"from expertsystem.amplitude.dynamics.builder import (\n",
142+
"from ampform.dynamics.builder import (\n",
141143
" create_non_dynamic_with_ff,\n",
142144
" create_relativistic_breit_wigner_with_ff,\n",
143145
")\n",
@@ -168,7 +170,7 @@
168170
"cell_type": "markdown",
169171
"metadata": {},
170172
"source": [
171-
"Finally, we can write the {class}`~expertsystem.amplitude.helicity.HelicityModel` to disk via {mod}`pickle`, as well as store the {class}`~expertsystem.reaction.Result` as JSON:"
173+
"Finally, we can write the {class}`~ampform.helicity.HelicityModel` to disk via {mod}`pickle`, as well as store the {class}`~qrules.transition.Result` as JSON:"
172174
]
173175
},
174176
{
@@ -179,7 +181,7 @@
179181
"source": [
180182
"import pickle\n",
181183
"\n",
182-
"es.io.write(result, \"transitions.json\")\n",
184+
"q.io.write(result, \"transitions.json\")\n",
183185
"with open(\"helicity_model.pickle\", \"wb\") as stream:\n",
184186
" pickle.dump(model, stream)"
185187
]
@@ -188,7 +190,7 @@
188190
"cell_type": "markdown",
189191
"metadata": {},
190192
"source": [
191-
"Cool, that's it! We now have a template for an amplitude model with which to {doc}`generate data <step2>` and {doc}`perform a fit <step3>`. In the next steps, we will use use this {class}`~expertsystem.amplitude.helicity.HelicityModel` as a fit model template for {mod}`tensorwaves`."
193+
"Cool, that's it! We now have a template for an amplitude model with which to {doc}`generate data <step2>` and {doc}`perform a fit <step3>`. In the next steps, we will use use this {class}`~ampform.helicity.HelicityModel` as a fit model template for {mod}`tensorwaves`."
192194
]
193195
}
194196
],

0 commit comments

Comments
 (0)