Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac #19576: parentheses around coefficients of asymptotic expansions
Browse files Browse the repository at this point in the history
  • Loading branch information
cheuberg committed Jan 15, 2016
1 parent a1b60f2 commit 8f7195f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/sage/rings/asymptotic/term_monoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3056,6 +3056,16 @@ def _repr_(self):
-x^2
sage: ET(x^0, 42)
42
Check that :trac:`19576` is fixed::
sage: C.<c> = AsymptoticRing('c^ZZ', SR)
sage: (1+pi)*c
(pi + 1)*c
sage: R.<a> = QQ[]
sage: S.<n> = AsymptoticRing('n^QQ', R)
sage: (1+a)/n
(a + 1)*n^(-1)
"""
g = repr(self.growth)
c = repr(self.coefficient)
Expand All @@ -3065,8 +3075,12 @@ def _repr_(self):
return '%s' % (g,)
elif c == '-1':
return '-%s' % (g,)
else:
elif self.coefficient._is_atomic() or (-self.coefficient)._is_atomic():
# note that -pi/2 is not atomic, but -5 is. As subtractions are handeled
# in the asymptotic ring, we ignore such non-atomicity.
return '%s*%s' % (c, g)
else:
return '(%s)*%s' % (c, g)


def __invert__(self):
Expand Down

0 comments on commit 8f7195f

Please sign in to comment.