From a957f7e92153376a50b30886b5eab2ae947abc26 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 4 Jul 2023 08:21:36 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/jpsi2ksp.ipynb | 4 +--- docs/lc2pkpi.ipynb | 4 +--- src/ampform_dpd/__init__.py | 19 +++++++------------ src/ampform_dpd/_attrs.py | 4 +--- src/ampform_dpd/angles.py | 17 ++++++++--------- src/ampform_dpd/decay.py | 16 ++++++++++------ src/ampform_dpd/io.py | 6 +++--- 7 files changed, 31 insertions(+), 39 deletions(-) diff --git a/docs/jpsi2ksp.ipynb b/docs/jpsi2ksp.ipynb index 2dfa7cba..620b819c 100644 --- a/docs/jpsi2ksp.ipynb +++ b/docs/jpsi2ksp.ipynb @@ -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)" ] }, { diff --git a/docs/lc2pkpi.ipynb b/docs/lc2pkpi.ipynb index a79a3658..cee23f16 100644 --- a/docs/lc2pkpi.ipynb +++ b/docs/lc2pkpi.ipynb @@ -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", diff --git a/src/ampform_dpd/__init__.py b/src/ampform_dpd/__init__.py index cbe5b367..6bc9b4e0 100644 --- a/src/ampform_dpd/__init__.py +++ b/src/ampform_dpd/__init__.py @@ -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: @@ -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) @@ -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) λ = { diff --git a/src/ampform_dpd/_attrs.py b/src/ampform_dpd/_attrs.py index 1a88e18d..509eb3d6 100644 --- a/src/ampform_dpd/_attrs.py +++ b/src/ampform_dpd/_attrs.py @@ -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: diff --git a/src/ampform_dpd/angles.py b/src/ampform_dpd/angles.py index b1e268b9..5a491000 100644 --- a/src/ampform_dpd/angles.py +++ b/src/ampform_dpd/angles.py @@ -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) @@ -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 @@ -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) @@ -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) diff --git a/src/ampform_dpd/decay.py b/src/ampform_dpd/decay.py index 095c5e68..56a67190 100644 --- a/src/ampform_dpd/decay.py +++ b/src/ampform_dpd/decay.py @@ -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: diff --git a/src/ampform_dpd/io.py b/src/ampform_dpd/io.py index 927e2fde..f0b38678 100644 --- a/src/ampform_dpd/io.py +++ b/src/ampform_dpd/io.py @@ -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: