From d0c10b95f253fb6ab0bfbbba13c17b5bbd1ada2e Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Fri, 6 Dec 2024 15:12:20 +0100 Subject: [PATCH] MAINT: simplify implementation --- src/qrules/particle.py | 5 ++--- src/qrules/quantum_numbers.py | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/qrules/particle.py b/src/qrules/particle.py index 175bdba0..cb382963 100644 --- a/src/qrules/particle.py +++ b/src/qrules/particle.py @@ -120,10 +120,9 @@ def _repr_pretty_(self, p: PrettyPrinter, _: bool) -> None: def _render_fraction(fraction: Fraction, plusminus: bool = False) -> str: - string_representation = str(fraction) if plusminus and fraction.numerator > 0: - return f"+{string_representation}" - return string_representation + return f"+{fraction}" + return str(fraction) def _to_parity(value: Parity | int) -> Parity: diff --git a/src/qrules/quantum_numbers.py b/src/qrules/quantum_numbers.py index cdf124fb..b3ce208c 100644 --- a/src/qrules/quantum_numbers.py +++ b/src/qrules/quantum_numbers.py @@ -58,10 +58,9 @@ def __repr__(self) -> str: def _float_as_signed_str(value: float, render_plus: bool = False) -> str: - string_representation = str(value) if value > 0 or render_plus: - return f"+{string_representation}" - return string_representation + return f"+{value}" + return str(value) @frozen(init=False)