Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 7, 2023
1 parent f50a41d commit b0dea63
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 46 deletions.
1 change: 1 addition & 0 deletions src/ampform_dpd/_attrs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Helper functions for constructing `attrs` decorated classes."""

from __future__ import annotations

from typing import TYPE_CHECKING, SupportsFloat
Expand Down
36 changes: 10 additions & 26 deletions src/ampform_dpd/angles.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,8 @@ def formulate_scattering_angle(
σj = sp.Symbol(f"sigma{sibling_id}", nonnegative=True)
σk = sp.Symbol(f"sigma{spectator_id}", nonnegative=True)
theta = sp.acos(
(
2 * σk * (σj - mk**2 - mi**2)
- (σk + mi**2 - mj**2) * (m0**2 - σk - mk**2)
)
/ (
sp.sqrt(Kallen(m0**2, mk**2, σk))
* sp.sqrt(Kallen(σk, mi**2, mj**2))
)
(2 * σk * (σj - mk**2 - mi**2) - (σk + mi**2 - mj**2) * (m0**2 - σk - mk**2))
/ (sp.sqrt(Kallen(m0**2, mk**2, σk)) * sp.sqrt(Kallen(σk, mi**2, mj**2)))
)
return symbol, theta

Expand Down Expand Up @@ -69,10 +63,7 @@ def formulate_theta_hat_angle(
(m0**2 + mi**2 - σi) * (m0**2 + mj**2 - σj)
- 2 * m0**2 * (σk - mi**2 - mj**2)
)
/ (
sp.sqrt(Kallen(m0**2, mj**2, σj))
* sp.sqrt(Kallen(m0**2, σi, mi**2))
)
/ (sp.sqrt(Kallen(m0**2, mj**2, σj)) * sp.sqrt(Kallen(m0**2, σi, mi**2)))
)
return symbol, theta
_, theta = formulate_theta_hat_angle(aligned_subsystem, isobar_id)
Expand Down Expand Up @@ -104,53 +95,47 @@ def formulate_zeta_angle( # noqa: C901, PLR0911
2 * m1**2 * (σ2 - m0**2 - m2**2)
+ (m0**2 + m1**2 - σ1) * (σ3 - m1**2 - m2**2)
) / (
sp.sqrt(Kallen(m0**2, m1**2, σ1))
* sp.sqrt(Kallen(σ3, m1**2, m2**2))
sp.sqrt(Kallen(m0**2, m1**2, σ1)) * sp.sqrt(Kallen(σ3, m1**2, m2**2))
)
return zeta_symbol, sp.acos(cos_zeta_expr)
if (rotated_state, aligned_subsystem, reference_subsystem) == (1, 2, 1):
cos_zeta_expr = (
2 * m1**2 * (σ3 - m0**2 - m3**2)
+ (m0**2 + m1**2 - σ1) * (σ2 - m1**2 - m3**2)
) / (
sp.sqrt(Kallen(m0**2, m1**2, σ1))
* sp.sqrt(Kallen(σ2, m1**2, m3**2))
sp.sqrt(Kallen(m0**2, m1**2, σ1)) * sp.sqrt(Kallen(σ2, m1**2, m3**2))
)
return zeta_symbol, sp.acos(cos_zeta_expr)
if (rotated_state, aligned_subsystem, reference_subsystem) == (2, 2, 1):
cos_zeta_expr = (
2 * m2**2 * (σ3 - m0**2 - m3**2)
+ (m0**2 + m2**2 - σ2) * (σ1 - m2**2 - m3**2)
) / (
sp.sqrt(Kallen(m0**2, m2**2, σ2))
* sp.sqrt(Kallen(σ1, m2**2, m3**2))
sp.sqrt(Kallen(m0**2, m2**2, σ2)) * sp.sqrt(Kallen(σ1, m2**2, m3**2))
)
return zeta_symbol, sp.acos(cos_zeta_expr)
if (rotated_state, aligned_subsystem, reference_subsystem) == (2, 3, 2):
cos_zeta_expr = (
2 * m2**2 * (σ1 - m0**2 - m1**2)
+ (m0**2 + m2**2 - σ2) * (σ3 - m2**2 - m1**2)
) / (
sp.sqrt(Kallen(m0**2, m2**2, σ2))
* sp.sqrt(Kallen(σ3, m2**2, m1**2))
sp.sqrt(Kallen(m0**2, m2**2, σ2)) * sp.sqrt(Kallen(σ3, m2**2, m1**2))
)
return zeta_symbol, sp.acos(cos_zeta_expr)
if (rotated_state, aligned_subsystem, reference_subsystem) == (3, 3, 2):
cos_zeta_expr = (
2 * m3**2 * (σ1 - m0**2 - m1**2)
+ (m0**2 + m3**2 - σ3) * (σ2 - m3**2 - m1**2)
) / (
sp.sqrt(Kallen(m0**2, m3**2, σ3))
* sp.sqrt(Kallen(σ2, m3**2, m1**2))
sp.sqrt(Kallen(m0**2, m3**2, σ3)) * sp.sqrt(Kallen(σ2, m3**2, m1**2))
)
return zeta_symbol, sp.acos(cos_zeta_expr)
if (rotated_state, aligned_subsystem, reference_subsystem) == (3, 1, 3):
cos_zeta_expr = (
2 * m3**2 * (σ2 - m0**2 - m2**2)
+ (m0**2 + m3**2 - σ3) * (σ1 - m3**2 - m2**2)
) / (
sp.sqrt(Kallen(m0**2, m3**2, σ3))
* sp.sqrt(Kallen(σ1, m3**2, m2**2))
sp.sqrt(Kallen(m0**2, m3**2, σ3)) * sp.sqrt(Kallen(σ1, m3**2, m2**2))
)
return zeta_symbol, sp.acos(cos_zeta_expr)
if (rotated_state, aligned_subsystem, reference_subsystem) in { # Eq (A10)
Expand All @@ -169,8 +154,7 @@ def create_symbols(i):
2 * mi**2 * (mj**2 + mk**2 - σi)
+ (σj - mi**2 - mk**2) * (σk - mi**2 - mj**2)
) / (
sp.sqrt(Kallen(σj, mk**2, mi**2))
* sp.sqrt(Kallen(σk, mi**2, mj**2))
sp.sqrt(Kallen(σj, mk**2, mi**2)) * sp.sqrt(Kallen(σk, mi**2, mj**2))
)
return zeta_symbol, sp.acos(cos_zeta_expr)
if (rotated_state, aligned_subsystem, reference_subsystem) in {
Expand Down
1 change: 1 addition & 0 deletions src/ampform_dpd/decay.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Data structures that describe a three-body decay."""

from __future__ import annotations

import sys
Expand Down
1 change: 1 addition & 0 deletions src/ampform_dpd/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
This code originates from `ComPWA/ampform#280
<https://github.com/ComPWA/ampform/pull/280>`_.
"""

from __future__ import annotations

import hashlib
Expand Down
25 changes: 5 additions & 20 deletions tests/test_angles.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,22 @@

def test_formulate_scattering_angle():
assert formulate_scattering_angle(2, 3)[1] == sp.acos(
(
2 * σ1 * (-(m1**2) - m2**2 + σ3)
- (m0**2 - m1**2 - σ1) * (m2**2 - m3**2 + σ1)
)
/ (
sp.sqrt(Kallen(m0**2, m1**2, σ1))
* sp.sqrt(Kallen(σ1, m2**2, m3**2))
)
(2 * σ1 * (-(m1**2) - m2**2 + σ3) - (m0**2 - m1**2 - σ1) * (m2**2 - m3**2 + σ1))
/ (sp.sqrt(Kallen(m0**2, m1**2, σ1)) * sp.sqrt(Kallen(σ1, m2**2, m3**2)))
)
assert formulate_scattering_angle(3, 1)[1] == sp.acos(
(
2 * σ2 * (-(m2**2) - m3**2 + σ1)
- (m0**2 - m2**2 - σ2) * (-(m1**2) + m3**2 + σ2)
)
/ (
sp.sqrt(Kallen(m0**2, m2**2, σ2))
* sp.sqrt(Kallen(σ2, m3**2, m1**2))
)
/ (sp.sqrt(Kallen(m0**2, m2**2, σ2)) * sp.sqrt(Kallen(σ2, m3**2, m1**2)))
)


def test_formulate_theta_hat_angle():
assert formulate_theta_hat_angle(1, 2)[1] == sp.acos(
(
(m0**2 + m1**2 - σ1) * (m0**2 + m2**2 - σ2)
- 2 * m0**2 * (σ3 - m1**2 - m2**2)
)
/ (
sp.sqrt(Kallen(m0**2, m2**2, σ2))
* sp.sqrt(Kallen(m0**2, σ1, m1**2))
)
((m0**2 + m1**2 - σ1) * (m0**2 + m2**2 - σ2) - 2 * m0**2 * (σ3 - m1**2 - m2**2))
/ (sp.sqrt(Kallen(m0**2, m2**2, σ2)) * sp.sqrt(Kallen(m0**2, σ1, m1**2)))
)
assert formulate_theta_hat_angle(1, 2)[1] == -formulate_theta_hat_angle(2, 1)[1]
for i in [1, 2, 3]:
Expand Down

0 comments on commit b0dea63

Please sign in to comment.