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

Commit

Permalink
Trac #19946: add doctests to document behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrenn committed Jan 26, 2016
1 parent 1fc00c7 commit 1b62954
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/sage/rings/asymptotic/asymptotic_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,14 @@ def __pow__(self, exponent, precision=None):
ValueError: Cannot take s + t to the exponent s.
> *previous* ValueError: log(s + t) cannot be constructed since
there are several maximal elements s, t.
Check that :trac:`19946` is fixed::
sage: A.<n> = AsymptoticRing('QQ^n * n^QQ', SR)
sage: 2^n
2^n
sage: _.parent()
Asymptotic Ring <SR^n * n^SR> over Symbolic Ring
"""
if not self.summands:
if exponent == 0:
Expand Down Expand Up @@ -1666,6 +1674,14 @@ def rpow(self, base, precision=None):
ArithmeticError: Cannot construct y^x in Growth Group x^ZZ
> *previous* TypeError: unsupported operand parent(s) for '*':
'Growth Group x^ZZ' and 'Growth Group SR^x'
Check that :trac:`19946` is fixed::
sage: A.<n> = AsymptoticRing('QQ^n * n^QQ', SR)
sage: n.rpow(2)
2^n
sage: _.parent()
Asymptotic Ring <QQ^n * n^SR> over Symbolic Ring
"""
if isinstance(base, AsymptoticExpansion):
return base.__pow__(self, precision=precision)
Expand Down
8 changes: 8 additions & 0 deletions src/sage/rings/asymptotic/growth_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,14 @@ def _rpow_(self, base):
sage: x = G('x')
sage: (x * log(x)).rpow(2) # indirect doctest
2^(x*log(x))
::
sage: n = GrowthGroup('QQ^n * n^QQ')('n')
sage: n.rpow(2)
2^n
sage: _.parent()
Growth Group QQ^n * n^QQ
"""
if base == 0:
raise ValueError('%s is not an allowed base for calculating the '
Expand Down
20 changes: 20 additions & 0 deletions src/sage/rings/asymptotic/term_monoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3308,6 +3308,26 @@ def rpow(self, base):
Growth Group QQ^x * x^ZZ * log(x)^ZZ
> *previous* TypeError: unsupported operand parent(s) for '*':
'Growth Group QQ^x * x^ZZ * log(x)^ZZ' and 'Growth Group ZZ^(x^2)'
::
sage: T = TermMonoid('exact', GrowthGroup('QQ^n * n^QQ'), SR)
sage: n = T('n')
sage: n.rpow(2)
2^n
sage: _.parent()
Exact Term Monoid QQ^n * n^SR with coefficients in Symbolic Ring
Above, we get ``QQ^n * n^SR`` since
::
sage: (n^SR(1)).parent()
Exact Term Monoid QQ^n * n^SR with coefficients in Symbolic Ring
and that is because of
sage: (QQ(2)^SR(1)).parent(), (QQ(1)*SR(1)).parent()
(Rational Field, Symbolic Ring)
"""
P = self.parent()

Expand Down

0 comments on commit 1b62954

Please sign in to comment.