Skip to content

Commit b89f351

Browse files
committed
rewrap
1 parent 0586d59 commit b89f351

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

petab/v1/math/printer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ def _print_Pow(self, expr: sp.Pow):
4141
str_exp = self._print(exp)
4242
if not base.is_Atom:
4343
str_base = f"({str_base})"
44-
# A non-integer Rational exponent (e.g. sqrt -> 1/2) is an Atom but prints as the
45-
# multi-token "1/2", so without parentheses "x ^ 1/2" re-parses as (x^1)/2. The
46-
# `not exp.is_Atom` check above (#421) misses it; parenthesize it explicitly.
44+
# A non-integer Rational exponent (e.g. sqrt -> 1/2) is an Atom but
45+
# prints as the multi-token "1/2", so without parentheses "x ^ 1/2"
46+
# re-parses as (x^1)/2. Parenthesize it explicitly.
4747
if not exp.is_Atom or (exp.is_Rational and not exp.is_Integer):
4848
str_exp = f"({str_exp})"
4949
return f"{str_base} ^ {str_exp}"

tests/v1/math/test_math.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def test_printer():
4343
assert petab_math_str(BooleanTrue()) == "true"
4444
assert petab_math_str(BooleanFalse()) == "false"
4545
assert petab_math_str((a + b) ** (c + d)) == "(a + b) ^ (c + d)"
46-
# A non-integer rational exponent must be parenthesized, else "a ^ 1/2" re-parses as
47-
# (a^1)/2 (i.e. sqrt(a) would round-trip to a/2). See #421 for the base/exponent case.
46+
# A non-integer rational exponent must be parenthesized, else "a ^ 1/2"
47+
# re-parses as (a^1)/2 (i.e. sqrt(a) would round-trip to a/2).
4848
assert petab_math_str(sp.sqrt(a)) == "a ^ (1/2)"
4949
assert petab_math_str(a ** sp.Rational(2, 3)) == "a ^ (2/3)"
5050

0 commit comments

Comments
 (0)