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 Jul 4, 2023
1 parent f78d70c commit a957f7e
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 39 deletions.
4 changes: 1 addition & 3 deletions docs/jpsi2ksp.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,7 @@
" if decay_masses == {m1, m2}:\n",
" return s3\n",
" msg = f\"Cannot find Mandelstam variable for {''.join(decay_masses)}\"\n",
" raise NotImplementedError(\n",
" msg\n",
" )"
" raise NotImplementedError(msg)"
]
},
{
Expand Down
4 changes: 1 addition & 3 deletions docs/lc2pkpi.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,7 @@
" if decay_masses == {m1, m2}:\n",
" return s3\n",
" msg = f\"Cannot find Mandelstam variable for {''.join(decay_masses)}\"\n",
" raise NotImplementedError(\n",
" msg\n",
" )\n",
" raise NotImplementedError(msg)\n",
"\n",
"\n",
"def _to_mass_symbol(particle: Particle) -> sp.Symbol:\n",
Expand Down
19 changes: 7 additions & 12 deletions src/ampform_dpd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,16 +310,12 @@ def __get_chain(self, identifier) -> ThreeBodyDecayChain:
chain = identifier
if chain not in set(self.__decay.chains):
msg = f"Decay does not have chain with resonance {chain.resonance.name}"
raise ValueError(
msg
)
raise ValueError(msg)
return chain
if isinstance(identifier, str):
return self.__decay.find_chain(identifier)
msg = f"Cannot get decay chain for identifier type {type(identifier)}"
raise NotImplementedError(
msg
)
raise NotImplementedError(msg)

@property
def decay(self) -> ThreeBodyDecay:
Expand Down Expand Up @@ -356,9 +352,7 @@ def _formulate_clebsch_gordan_factors(
) -> sp.Expr:
if isobar.interaction is None:
msg = "Cannot formulate amplitude model in LS-basis if LS-couplings are missing"
raise ValueError(
msg
)
raise ValueError(msg)
# https://github.com/ComPWA/ampform/blob/65b4efa/src/ampform/helicity/__init__.py#L785-L802
# and supplementary material p.1 (https://cds.cern.ch/record/2824328/files)
child1 = _get_particle(isobar.child1)
Expand Down Expand Up @@ -399,10 +393,11 @@ def formulate_polarimetry(
) -> tuple[PoolSum, PoolSum, PoolSum]:
half = sp.Rational(1, 2)
if builder.decay.initial_state.spin != half:
msg = f"Can only formulate polarimetry for an initial state with spin 1/2, but got {builder.decay.initial_state.spin}"
raise ValueError(
msg
msg = (
"Can only formulate polarimetry for an initial state with spin 1/2, but"
f" got {builder.decay.initial_state.spin}"
)
raise ValueError(msg)
model = builder.formulate(reference_subsystem)
λ0, λ0_prime = sp.symbols(R"lambda \lambda^{\prime}", rational=True)
λ = {
Expand Down
4 changes: 1 addition & 3 deletions src/ampform_dpd/_attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
def assert_spin_value(instance, attribute: Attribute, value: sp.Rational) -> None:
if value.denominator not in {1, 2}:
msg = f"{attribute.name} value should be integer or half-integer, not {value}"
raise ValueError(
msg
)
raise ValueError(msg)


def to_ls(obj: LSCoupling | tuple[int, SupportsFloat] | None) -> LSCoupling:
Expand Down
17 changes: 8 additions & 9 deletions src/ampform_dpd/angles.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ def formulate_scattering_angle(
# pyright: ignore[reportUnnecessaryContains]
if {state_id, sibling_id} in {(2, 1), (3, 2), (1, 3)}:
msg = f"Cannot compute scattering angle θ{state_id}{sibling_id}"
raise NotImplementedError(
msg
)
raise NotImplementedError(msg)
if state_id == sibling_id:
msg = f"IDs of the decay products cannot be equal: {state_id}"
raise ValueError(msg)
Expand Down Expand Up @@ -54,9 +52,7 @@ def formulate_theta_hat_angle(
allowed_ids = {1, 2, 3}
if not {isobar_id, aligned_subsystem} <= allowed_ids:
msg = f"Child IDs need to be one of {', '.join(map(str, allowed_ids))}"
raise ValueError(
msg
)
raise ValueError(msg)
symbol = sp.Symbol(Rf"\hat\theta_{isobar_id}({aligned_subsystem})", real=True)
if isobar_id == aligned_subsystem:
return symbol, sp.S.Zero
Expand Down Expand Up @@ -162,8 +158,10 @@ def formulate_zeta_angle(
(2, 3, 1),
(3, 1, 2),
}:

def create_symbols(i):
return sp.symbols(f"m{i} sigma{i}", nonnegative=True)

mi, σi = create_symbols(rotated_state)
mj, σj = create_symbols(aligned_subsystem)
mk, σk = create_symbols(reference_subsystem)
Expand All @@ -190,7 +188,8 @@ def create_symbols(i):
rotated_state, reference_subsystem, aligned_subsystem
)
return zeta_symbol, -zeta
msg = f"No expression for ζ^{rotated_state}_{aligned_subsystem}({reference_subsystem})"
raise NotImplementedError(
msg
msg = (
"No expression for"
f" ζ^{rotated_state}_{aligned_subsystem}({reference_subsystem})"
)
raise NotImplementedError(msg)
16 changes: 10 additions & 6 deletions src/ampform_dpd/decay.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,22 @@ def __attrs_post_init__(self) -> None:
expected_final_state = set(self.final_state.values())
for i, chain in enumerate(self.chains):
if chain.parent != expected_initial_state:
msg = f"Chain {i} has initial state {chain.parent.name}, but should have {expected_initial_state.name}"
raise ValueError(
msg
msg = (
f"Chain {i} has initial state {chain.parent.name}, but should have"
f" {expected_initial_state.name}"
)
raise ValueError(msg)
final_state = {chain.spectator, *chain.decay_products}
if final_state != expected_final_state:

def to_str(s):
return ", ".join(p.name for p in s)
msg = f"Chain {i} has final state {to_str(final_state)}, but should have {to_str(expected_final_state)}"
raise ValueError(
msg

msg = (
f"Chain {i} has final state {to_str(final_state)}, but should have"
f" {to_str(expected_final_state)}"
)
raise ValueError(msg)

@property
def initial_state(self) -> Particle:
Expand Down
6 changes: 3 additions & 3 deletions src/ampform_dpd/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ def as_markdown_table(obj: Sequence) -> str:
return _as_decay_markdown_table(obj.chains)
if item_type is ThreeBodyDecayChain:
return _as_decay_markdown_table(obj)
msg = f"Cannot render a sequence with {item_type.__name__} items as a Markdown table"
raise NotImplementedError(
msg
msg = (
f"Cannot render a sequence with {item_type.__name__} items as a Markdown table"
)
raise NotImplementedError(msg)


def _determine_item_type(obj) -> type:
Expand Down

0 comments on commit a957f7e

Please sign in to comment.