Skip to content

Commit

Permalink
MAINT: simplify implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Dec 6, 2024
1 parent 33e9009 commit d0c10b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/qrules/particle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions src/qrules/quantum_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d0c10b9

Please sign in to comment.