From 182d69bf610e16516e56be6c9a17437ba0fd8087 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 24 Dec 2024 12:54:14 +0100 Subject: [PATCH] FIX: use AmpForm's `FormFactor` (#148) * MAINT: update lock file to 0.2.1 * MAINT: upgrade Jupyter kernels --- docs/jpsi2ksp.ipynb | 7 +++--- docs/serialization.ipynb | 5 ++--- docs/xib2pkk.ipynb | 7 +++--- pyproject.toml | 2 +- src/ampform_dpd/dynamics/__init__.py | 23 +------------------- src/ampform_dpd/dynamics/builder.py | 3 ++- src/ampform_dpd/io/serialization/dynamics.py | 8 ++----- uv.lock | 4 ++-- 8 files changed, 18 insertions(+), 41 deletions(-) diff --git a/docs/jpsi2ksp.ipynb b/docs/jpsi2ksp.ipynb index f61c08b9..52ef49a4 100644 --- a/docs/jpsi2ksp.ipynb +++ b/docs/jpsi2ksp.ipynb @@ -36,7 +36,8 @@ "import matplotlib.pyplot as plt\n", "import qrules\n", "import sympy as sp\n", - "from ampform.dynamics import BlattWeisskopfSquared, EnergyDependentWidth\n", + "from ampform.dynamics import EnergyDependentWidth\n", + "from ampform.dynamics.form_factor import BlattWeisskopfSquared, FormFactor\n", "from ampform.sympy import perform_cached_doit\n", "from IPython.display import Latex, Markdown\n", "from tensorwaves.data.transform import SympyDataTransformer\n", @@ -45,7 +46,7 @@ "from ampform_dpd import DalitzPlotDecompositionBuilder\n", "from ampform_dpd.adapter.qrules import normalize_state_ids, to_three_body_decay\n", "from ampform_dpd.decay import State\n", - "from ampform_dpd.dynamics import FormFactor, RelativisticBreitWigner\n", + "from ampform_dpd.dynamics import RelativisticBreitWigner\n", "from ampform_dpd.dynamics.builder import formulate_breit_wigner_with_form_factor\n", "from ampform_dpd.io import (\n", " as_markdown_table,\n", @@ -575,7 +576,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.19" + "version": "3.12.8" } }, "nbformat": 4, diff --git a/docs/serialization.ipynb b/docs/serialization.ipynb index d2a8e2b3..de5d4167 100644 --- a/docs/serialization.ipynb +++ b/docs/serialization.ipynb @@ -49,7 +49,7 @@ "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "import sympy as sp\n", - "from ampform.dynamics import BlattWeisskopfSquared\n", + "from ampform.dynamics.form_factor import BlattWeisskopfSquared, FormFactor\n", "from ampform.dynamics.phasespace import BreakupMomentumSquared\n", "from ampform.kinematics.phasespace import Kallen\n", "from ampform.sympy import perform_cached_doit\n", @@ -63,7 +63,6 @@ " BuggBreitWigner,\n", " ChannelArguments,\n", " EnergyDependentWidth,\n", - " FormFactor,\n", " MultichannelBreitWigner,\n", " P,\n", " SimpleBreitWigner,\n", @@ -980,7 +979,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.19" + "version": "3.12.8" } }, "nbformat": 4, diff --git a/docs/xib2pkk.ipynb b/docs/xib2pkk.ipynb index 6acb0ad1..cc34b0f0 100644 --- a/docs/xib2pkk.ipynb +++ b/docs/xib2pkk.ipynb @@ -36,7 +36,8 @@ "import matplotlib.pyplot as plt\n", "import qrules\n", "import sympy as sp\n", - "from ampform.dynamics import BlattWeisskopfSquared, EnergyDependentWidth\n", + "from ampform.dynamics import EnergyDependentWidth\n", + "from ampform.dynamics.form_factor import BlattWeisskopfSquared, FormFactor\n", "from ampform.sympy import perform_cached_doit\n", "from IPython.display import Latex, Markdown\n", "from tensorwaves.data.transform import SympyDataTransformer\n", @@ -50,7 +51,7 @@ " to_three_body_decay,\n", ")\n", "from ampform_dpd.decay import State\n", - "from ampform_dpd.dynamics import FormFactor, RelativisticBreitWigner\n", + "from ampform_dpd.dynamics import RelativisticBreitWigner\n", "from ampform_dpd.dynamics.builder import formulate_breit_wigner_with_form_factor\n", "from ampform_dpd.io import (\n", " as_markdown_table,\n", @@ -585,7 +586,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.19" + "version": "3.12.8" } }, "nbformat": 4, diff --git a/pyproject.toml b/pyproject.toml index 4c8d08f0..1db0f989 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ classifiers = [ "Typing :: Typed", ] dependencies = [ - "ampform >=0.15.1", # aslatex with keyword arguments + "ampform >=0.15.4", # aslatex with keyword arguments "attrs >=20.1.0", # on_setattr and https://www.attrs.org/en/stable/api.html#next-gen "cloudpickle", "numpy", diff --git a/src/ampform_dpd/dynamics/__init__.py b/src/ampform_dpd/dynamics/__init__.py index 92d5b706..cbd9c45c 100644 --- a/src/ampform_dpd/dynamics/__init__.py +++ b/src/ampform_dpd/dynamics/__init__.py @@ -6,7 +6,7 @@ from typing import TYPE_CHECKING, Any import sympy as sp -from ampform.dynamics import formulate_form_factor +from ampform.dynamics.form_factor import FormFactor from ampform.kinematics.phasespace import Kallen from ampform.sympy import unevaluated @@ -195,27 +195,6 @@ def evaluate(self) -> sp.Piecewise: ]) -@unevaluated -class FormFactor(sp.Expr): - s: Any - m1: Any - m2: Any - angular_momentum: Any - meson_radius: Any - - _latex_repr_ = R"\mathcal{{F}}_{{{angular_momentum}}}\left({s}, {m1}, {m2}\right)" - - def evaluate(self): - s, m1, m2, angular_momentum, meson_radius = self.args - return formulate_form_factor( - s=s, - m_a=m1, - m_b=m2, - angular_momentum=angular_momentum, - meson_radius=meson_radius, - ) - - @unevaluated class MultichannelBreitWigner(sp.Expr): s: Any diff --git a/src/ampform_dpd/dynamics/builder.py b/src/ampform_dpd/dynamics/builder.py index a6a1fa46..279b249d 100644 --- a/src/ampform_dpd/dynamics/builder.py +++ b/src/ampform_dpd/dynamics/builder.py @@ -9,6 +9,7 @@ from __future__ import annotations import sympy as sp +from ampform.dynamics.form_factor import FormFactor from ampform_dpd import to_particle from ampform_dpd.decay import ( @@ -18,7 +19,7 @@ State, ThreeBodyDecayChain, ) -from ampform_dpd.dynamics import FormFactor, RelativisticBreitWigner +from ampform_dpd.dynamics import RelativisticBreitWigner def formulate_breit_wigner_with_form_factor( diff --git a/src/ampform_dpd/io/serialization/dynamics.py b/src/ampform_dpd/io/serialization/dynamics.py index 718c7be7..56dd2275 100644 --- a/src/ampform_dpd/io/serialization/dynamics.py +++ b/src/ampform_dpd/io/serialization/dynamics.py @@ -4,14 +4,10 @@ from typing import TYPE_CHECKING, Callable, Protocol, TypeVar, cast import sympy as sp +from ampform.dynamics.form_factor import FormFactor from ampform_dpd import DefinedExpression -from ampform_dpd.dynamics import ( - BreitWigner, - ChannelArguments, - FormFactor, - MultichannelBreitWigner, -) +from ampform_dpd.dynamics import BreitWigner, ChannelArguments, MultichannelBreitWigner from ampform_dpd.io.serialization.decay import get_initial_state from ampform_dpd.io.serialization.format import ( BlattWeisskopfDefinition, diff --git a/uv.lock b/uv.lock index 8233eb7d..b4b6ab53 100644 --- a/uv.lock +++ b/uv.lock @@ -73,7 +73,7 @@ wheels = [ [[package]] name = "ampform-dpd" -version = "0.2.1rc0" +version = "0.2.1" source = { editable = "." } dependencies = [ { name = "ampform" }, @@ -191,7 +191,7 @@ types = [ [package.metadata] requires-dist = [ - { name = "ampform", specifier = ">=0.15.1" }, + { name = "ampform", specifier = ">=0.15.4" }, { name = "attrs", specifier = ">=20.1.0" }, { name = "cloudpickle" }, { name = "numpy" },