Skip to content

Commit

Permalink
BREAK: switch arguments of BlattWeisskopfSquared
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Dec 18, 2023
1 parent cd37c6d commit 7d48525
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions docs/_extend_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ def extend_docstrings() -> None:
def extend_BlattWeisskopfSquared() -> None:
from ampform.dynamics import BlattWeisskopfSquared

L = sp.Symbol("L", integer=True)
z = sp.Symbol("z", real=True)
expr = BlattWeisskopfSquared(L, z)
L = sp.Symbol("L", integer=True)
expr = BlattWeisskopfSquared(z, angular_momentum=L)
_append_latex_doit_definition(expr, deep=True, full_width=True)


Expand Down
4 changes: 2 additions & 2 deletions docs/usage/dynamics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
"\n",
"L = sp.Symbol(\"L\", integer=True)\n",
"z = sp.Symbol(\"z\", real=True)\n",
"ff2 = BlattWeisskopfSquared(L, z)\n",
"ff2 = BlattWeisskopfSquared(z, L)\n",
"Math(sp.multiline_latex(ff2, ff2.doit(), environment=\"eqnarray\"))"
]
},
Expand All @@ -183,7 +183,7 @@
"m, m_a, m_b, d = sp.symbols(\"m, m_a, m_b, d\")\n",
"s = m**2\n",
"q_squared = BreakupMomentumSquared(s, m_a, m_b)\n",
"ff2 = BlattWeisskopfSquared(L, z=q_squared * d**2)"
"ff2 = BlattWeisskopfSquared(q_squared * d**2, angular_momentum=L)"
]
},
{
Expand Down
16 changes: 8 additions & 8 deletions src/ampform/dynamics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class BlattWeisskopfSquared(sp.Expr):
r"""Blatt-Weisskopf function :math:`B_L^2(z)`, up to :math:`L \leq 8`.
Args:
angular_momentum: Angular momentum :math:`L` of the decaying particle.
z: Argument of the Blatt-Weisskopf function :math:`B_L^2(z)`. A usual
choice is :math:`z = (d q)^2` with :math:`d` the impact parameter and
:math:`q` the breakup-momentum (see `.BreakupMomentumSquared`).
angular_momentum: Angular momentum :math:`L` of the decaying particle.
Note that equal powers of :math:`z` appear in the nominator and the denominator,
while some sources have nominator :math:`1`, instead of :math:`z^L`. Compare for
instance Equation (50.27) in :pdg-review:`2021; Resonances; p.9`.
Expand All @@ -57,8 +57,8 @@ class BlattWeisskopfSquared(sp.Expr):
See also :ref:`usage/dynamics:Form factor`.
"""
angular_momentum: Any
z: Any
angular_momentum: Any
_latex_repr_ = R"B_{{{angular_momentum}}}^2\left({z}\right)"

max_angular_momentum: ClassVar[int | None] = None
Expand All @@ -69,8 +69,8 @@ class BlattWeisskopfSquared(sp.Expr):
"""

def evaluate(self) -> sp.Expr:
angular_momentum: sp.Expr = self.args[0] # type: ignore[assignment]
z: sp.Expr = self.args[1] # type: ignore[assignment]
z: sp.Expr = self.args[0] # type: ignore[assignment]
angular_momentum: sp.Expr = self.args[1] # type: ignore[assignment]
cases: dict[int, sp.Expr] = {
0: sp.S.One,
1: 2 * z / (z + 1),
Expand Down Expand Up @@ -204,12 +204,12 @@ def evaluate(self) -> sp.Expr:
q_squared = BreakupMomentumSquared(s, m_a, m_b)
q0_squared = BreakupMomentumSquared(mass0**2, m_a, m_b) # type: ignore[operator]
form_factor_sq = BlattWeisskopfSquared(
q_squared * meson_radius**2, # type: ignore[operator]
angular_momentum,
z=q_squared * meson_radius**2, # type: ignore[operator]
)
form_factor0_sq = BlattWeisskopfSquared(
q0_squared * meson_radius**2, # type: ignore[operator]
angular_momentum,
z=q0_squared * meson_radius**2, # type: ignore[operator]
)
rho = self.phsp_factor(s, m_a, m_b)
rho0 = self.phsp_factor(mass0**2, m_a, m_b) # type: ignore[operator]
Expand Down Expand Up @@ -299,5 +299,5 @@ def formulate_form_factor(s, m_a, m_b, angular_momentum, meson_radius) -> sp.Exp
`~sympy.functions.elementary.miscellaneous.sqrt` of a `.BlattWeisskopfSquared`.
"""
q_squared = BreakupMomentumSquared(s, m_a, m_b)
ff_squared = BlattWeisskopfSquared(angular_momentum, z=q_squared * meson_radius**2)
ff_squared = BlattWeisskopfSquared(q_squared * meson_radius**2, angular_momentum)
return sp.sqrt(ff_squared)
2 changes: 1 addition & 1 deletion tests/dynamics/test_dynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TestBlattWeisskopfSquared:
def test_max_angular_momentum(self):
z = sp.Symbol("z")
angular_momentum = sp.Symbol("L", integer=True)
form_factor = BlattWeisskopfSquared(angular_momentum, z=z)
form_factor = BlattWeisskopfSquared(z, angular_momentum)
form_factor_9 = form_factor.subs(angular_momentum, 8).evaluate()
factor, z_power, _ = form_factor_9.args
assert factor == 4392846440677
Expand Down
2 changes: 1 addition & 1 deletion tests/dynamics/test_sympy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_pickle():
assert expr == imported_expr

# Pickle classes derived from UnevaluatedExpression
expr = BlattWeisskopfSquared(angular_momentum, z=z)
expr = BlattWeisskopfSquared(z, angular_momentum)
pickled_obj = pickle.dumps(expr)
imported_expr = pickle.loads(pickled_obj) # noqa: S301
assert expr == imported_expr
Expand Down
12 changes: 6 additions & 6 deletions tests/sympy/test_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ def test_get_readable_hash_large(amplitude_model: tuple[str, HelicityModel]):
# https://github.com/ComPWA/ampform/actions/runs/3277058875/jobs/5393849802
# https://github.com/ComPWA/ampform/actions/runs/3277143883/jobs/5394043014
expected_hash = {
"canonical-helicity": "pythonhashseed-0-2810545974244949713",
"helicity": "pythonhashseed-0+7376549944210451653",
"canonical-helicity": "pythonhashseed-0-3873186712292274641",
"helicity": "pythonhashseed-0-8800154542426799839",
}[formalism]
elif sys.version_info >= (3, 11):
expected_hash = {
"canonical-helicity": "pythonhashseed-0-3472750730904901316",
"helicity": "pythonhashseed-0-6929663921313890862",
"canonical-helicity": "pythonhashseed-0+4035132515642199515",
"helicity": "pythonhashseed-0-2843057473565885663",
}[formalism]
else:
expected_hash = {
"canonical-helicity": "pythonhashseed-0+3198785896067421186",
"helicity": "pythonhashseed-0-2637772876619854778",
"canonical-helicity": "pythonhashseed-0+3420919389670627445",
"helicity": "pythonhashseed-0-6681863313351758450",
}[formalism]
assert get_readable_hash(model.expression) == expected_hash

0 comments on commit 7d48525

Please sign in to comment.