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

Commit

Permalink
Merge branch 't/32214/term-monoids-unify-repr' into t/32215/refactor-…
Browse files Browse the repository at this point in the history
…element-construction-term-monoids

* t/32214/term-monoids-unify-repr:
  Trac #32214: unify dash in monoid repr
  • Loading branch information
dkrenn committed Aug 9, 2021
2 parents 3c5c0f0 + 2f9c6b6 commit f7c1823
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions src/sage/rings/asymptotic/term_monoid.py
Expand Up @@ -596,14 +596,14 @@ def _calculate_pow_(self, exponent, new_coefficient=None):
sage: t._calculate_pow_(3, new_coefficient=2)
Traceback (most recent call last):
...
ValueError: Coefficient 2 is not 1, but GenericTerm-Monoid z^ZZ with
ValueError: Coefficient 2 is not 1, but GenericTerm Monoid z^ZZ with
(implicit) coefficients in Integer Ring does not support coefficients.
sage: t._calculate_pow_(-2)
Generic Term with growth z^(-2)
sage: t._calculate_pow_(-2, new_coefficient=2)
Traceback (most recent call last):
...
ValueError: Coefficient 2 is not 1, but GenericTerm-Monoid z^ZZ with
ValueError: Coefficient 2 is not 1, but GenericTerm Monoid z^ZZ with
(implicit) coefficients in Integer Ring does not support coefficients.
"""
try:
Expand Down Expand Up @@ -1151,14 +1151,14 @@ def is_little_o_of_one(self):
...
NotImplementedError: Cannot check whether Generic Term with growth x is o(1)
in the abstract base class
GenericTerm-Monoid x^ZZ with (implicit) coefficients in Rational Field.
GenericTerm Monoid x^ZZ with (implicit) coefficients in Rational Field.
sage: T = TermWithCoefficientMonoid(TermMonoid, GrowthGroup('x^ZZ'), QQ)
sage: T.an_element().is_little_o_of_one()
Traceback (most recent call last):
...
NotImplementedError: Cannot check whether Term with coefficient 1/2 and growth x
is o(1) in the abstract base class
TermWithCoefficient-Monoid x^ZZ with coefficients in Rational Field.
TermWithCoefficient Monoid x^ZZ with coefficients in Rational Field.
"""
raise NotImplementedError('Cannot check whether %s is o(1) in the '
'abstract base class %s.' % (self, self.parent()))
Expand Down Expand Up @@ -1188,7 +1188,7 @@ def rpow(self, base):
...
NotImplementedError: Cannot take e to the exponent
Generic Term with growth x*log(x) in the abstract base class
GenericTerm-Monoid x^ZZ * log(x)^ZZ with (implicit) coefficients in Rational Field.
GenericTerm Monoid x^ZZ * log(x)^ZZ with (implicit) coefficients in Rational Field.
"""
raise NotImplementedError('Cannot take %s to the exponent %s in the '
'abstract base class %s.' % (base, self, self.parent()))
Expand Down Expand Up @@ -1271,9 +1271,9 @@ def _substitute_(self, rules):
Traceback (most recent call last):
...
TypeError: Cannot substitute in Generic Term with growth x in
GenericTerm-Monoid x^ZZ with (implicit) coefficients in Integer Ring.
GenericTerm Monoid x^ZZ with (implicit) coefficients in Integer Ring.
> *previous* TypeError: Cannot substitute in the abstract base class
GenericTerm-Monoid x^ZZ with (implicit) coefficients in Integer Ring.
GenericTerm Monoid x^ZZ with (implicit) coefficients in Integer Ring.
"""
from .misc import substitute_raise_exception
substitute_raise_exception(self, TypeError(
Expand Down Expand Up @@ -1407,9 +1407,9 @@ class GenericTermMonoid(UniqueRepresentation, Parent, WithLocals):
sage: T_x_ZZ = GenericTermMonoid(TermMonoid, G_x, QQ)
sage: T_y_QQ = GenericTermMonoid(TermMonoid, G_y, QQ)
sage: T_x_ZZ
GenericTerm-Monoid x^ZZ with (implicit) coefficients in Rational Field
GenericTerm Monoid x^ZZ with (implicit) coefficients in Rational Field
sage: T_y_QQ
GenericTerm-Monoid y^QQ with (implicit) coefficients in Rational Field
GenericTerm Monoid y^QQ with (implicit) coefficients in Rational Field
"""

# enable the category framework for elements
Expand Down Expand Up @@ -1490,12 +1490,12 @@ def __init__(self, term_monoid_factory, growth_group, coefficient_ring, category
sage: G_x = GrowthGroup('x^ZZ')
sage: T_x = GenericTermMonoid(TermMonoid, G_x, QQ); T_x
GenericTerm-Monoid x^ZZ with (implicit) coefficients in Rational Field
GenericTerm Monoid x^ZZ with (implicit) coefficients in Rational Field
sage: T_x.growth_group
Growth Group x^ZZ
sage: G_y = GrowthGroup('y^QQ')
sage: T_y = GenericTermMonoid(TermMonoid, G_y, QQ); T_y
GenericTerm-Monoid y^QQ with (implicit) coefficients in Rational Field
GenericTerm Monoid y^QQ with (implicit) coefficients in Rational Field
sage: T_x is T_y
False
Expand All @@ -1510,9 +1510,9 @@ def __init__(self, term_monoid_factory, growth_group, coefficient_ring, category
sage: G = GrowthGroup('x^ZZ')
sage: T_ZZ = TermWithCoefficientMonoid(TermMonoid, G, ZZ); T_ZZ
TermWithCoefficient-Monoid x^ZZ with coefficients in Integer Ring
TermWithCoefficient Monoid x^ZZ with coefficients in Integer Ring
sage: T_QQ = TermWithCoefficientMonoid(TermMonoid, G, QQ); T_QQ
TermWithCoefficient-Monoid x^ZZ with coefficients in Rational Field
TermWithCoefficient Monoid x^ZZ with coefficients in Rational Field
sage: T_QQ.category()
Join of Category of monoids and Category of posets
"""
Expand Down Expand Up @@ -1671,11 +1671,11 @@ def _repr_(self):
sage: TermMonoid = TermMonoidFactory('__main__.TermMonoid')
sage: GenericTermMonoid(TermMonoid, GenericGrowthGroup(ZZ), QQ)._repr_()
'GenericTerm-Monoid Generic(ZZ) with (implicit) coefficients in Rational Field'
'GenericTerm Monoid Generic(ZZ) with (implicit) coefficients in Rational Field'
sage: GenericTermMonoid(TermMonoid, GrowthGroup('x^ZZ'), QQ)._repr_()
'GenericTerm-Monoid x^ZZ with (implicit) coefficients in Rational Field'
'GenericTerm Monoid x^ZZ with (implicit) coefficients in Rational Field'
"""
return 'GenericTerm-Monoid %s with (implicit) coefficients in %s' % \
return 'GenericTerm Monoid %s with (implicit) coefficients in %s' % \
(self.growth_group._repr_short_(), self.coefficient_ring)

def _coerce_map_from_(self, S):
Expand Down Expand Up @@ -1707,14 +1707,14 @@ def _coerce_map_from_(self, S):
sage: G_ZZ = GrowthGroup('x^ZZ')
sage: T_ZZ = GenericTermMonoid(TermMonoid, G_ZZ, QQ); T_ZZ
GenericTerm-Monoid x^ZZ with (implicit) coefficients in Rational Field
GenericTerm Monoid x^ZZ with (implicit) coefficients in Rational Field
sage: G_QQ = GrowthGroup('x^QQ')
sage: T_QQ = GenericTermMonoid(TermMonoid, G_QQ, QQ); T_QQ
GenericTerm-Monoid x^QQ with (implicit) coefficients in Rational Field
GenericTerm Monoid x^QQ with (implicit) coefficients in Rational Field
sage: T_QQ.has_coerce_map_from(T_ZZ) # indirect doctest
True
sage: T_QQ_ZZ = GenericTermMonoid(TermMonoid, G_QQ, ZZ); T_QQ_ZZ
GenericTerm-Monoid x^QQ with (implicit) coefficients in Integer Ring
GenericTerm Monoid x^QQ with (implicit) coefficients in Integer Ring
sage: T_QQ.has_coerce_map_from(T_QQ_ZZ)
True
sage: T_QQ_ZZ.has_coerce_map_from(T_QQ)
Expand All @@ -1724,9 +1724,9 @@ def _coerce_map_from_(self, S):
sage: from sage.rings.asymptotic.term_monoid import TermWithCoefficientMonoid
sage: TC_ZZ = TermWithCoefficientMonoid(TermMonoid, G_ZZ, ZZ); TC_ZZ
TermWithCoefficient-Monoid x^ZZ with coefficients in Integer Ring
TermWithCoefficient Monoid x^ZZ with coefficients in Integer Ring
sage: TC_QQ = TermWithCoefficientMonoid(TermMonoid, G_QQ, QQ); TC_QQ
TermWithCoefficient-Monoid x^QQ with coefficients in Rational Field
TermWithCoefficient Monoid x^QQ with coefficients in Rational Field
sage: TC_QQ.has_coerce_map_from(TC_ZZ) # indirect doctest
True
sage: TC_ZZ.has_coerce_map_from(TC_QQ) # indirect doctest
Expand Down Expand Up @@ -1773,9 +1773,9 @@ def _element_constructor_(self, data, *args, **kwds):
a common parent has to be found::
sage: term1.parent()
GenericTerm-Monoid x^ZZ with (implicit) coefficients in Rational Field
GenericTerm Monoid x^ZZ with (implicit) coefficients in Rational Field
sage: term2.parent()
GenericTerm-Monoid x^QQ with (implicit) coefficients in Rational Field
GenericTerm Monoid x^QQ with (implicit) coefficients in Rational Field
sage: term1 <= term2
True
Expand All @@ -1799,7 +1799,7 @@ def _element_constructor_(self, data, *args, **kwds):
sage: T_ZZ(10 * x^2)
Traceback (most recent call last):
...
ValueError: 10*x^2 is not in GenericTerm-Monoid x^ZZ
ValueError: 10*x^2 is not in GenericTerm Monoid x^ZZ
with (implicit) coefficients in Rational Field.
> *previous* ValueError: Factor 10*x^2 of 10*x^2 is neither a
coefficient (in Rational Field) nor growth (in Growth Group x^ZZ).
Expand Down Expand Up @@ -3159,7 +3159,7 @@ def __init__(self, parent, growth, coefficient):
...
ValueError: Cannot create TermWithCoefficient(x)
since given coefficient 1/2 is not valid in
TermWithCoefficient-Monoid x^ZZ with coefficients in Integer Ring.
TermWithCoefficient Monoid x^ZZ with coefficients in Integer Ring.
> *previous* TypeError: no conversion of this rational to integer
sage: CT_QQ(x, coefficient=1/2)
Term with coefficient 1/2 and growth x
Expand All @@ -3170,7 +3170,7 @@ def __init__(self, parent, growth, coefficient):
Traceback (most recent call last):
...
ZeroCoefficientError: Zero coefficient 0 is not allowed in
TermWithCoefficient-Monoid x^ZZ with coefficients in Integer Ring.
TermWithCoefficient Monoid x^ZZ with coefficients in Integer Ring.
The conversion of growth elements also works for the creation
of terms with coefficient::
Expand Down Expand Up @@ -3340,7 +3340,7 @@ def _calculate_pow_(self, exponent):
Traceback (most recent call last):
...
ArithmeticError: Cannot take Term with coefficient 0.? + 0.?*I and
growth z to the exponent I in TermWithCoefficient-Monoid z^ZZ with
growth z to the exponent I in TermWithCoefficient Monoid z^ZZ with
coefficients in Complex Interval Field with
53 bits of precision since its coefficient 0.? + 0.?*I
cannot be taken to this exponent.
Expand Down Expand Up @@ -3481,15 +3481,15 @@ class TermWithCoefficientMonoid(GenericTermMonoid):
sage: G_ZZ = GrowthGroup('x^ZZ'); x_ZZ = G_ZZ.gen()
sage: G_QQ = GrowthGroup('x^QQ'); x_QQ = G_QQ.gen()
sage: TC_ZZ = TermWithCoefficientMonoid(TermMonoid, G_ZZ, QQ); TC_ZZ
TermWithCoefficient-Monoid x^ZZ with coefficients in Rational Field
TermWithCoefficient Monoid x^ZZ with coefficients in Rational Field
sage: TC_QQ = TermWithCoefficientMonoid(TermMonoid, G_QQ, QQ); TC_QQ
TermWithCoefficient-Monoid x^QQ with coefficients in Rational Field
TermWithCoefficient Monoid x^QQ with coefficients in Rational Field
sage: TC_ZZ == TC_QQ or TC_ZZ is TC_QQ
False
sage: TC_QQ.coerce_map_from(TC_ZZ)
Coercion map:
From: TermWithCoefficient-Monoid x^ZZ with coefficients in Rational Field
To: TermWithCoefficient-Monoid x^QQ with coefficients in Rational Field
From: TermWithCoefficient Monoid x^ZZ with coefficients in Rational Field
To: TermWithCoefficient Monoid x^QQ with coefficients in Rational Field
"""

# enable the category framework for elements
Expand All @@ -3515,11 +3515,11 @@ def _repr_(self):
sage: TermMonoid = TermMonoidFactory('__main__.TermMonoid')
sage: TermWithCoefficientMonoid(TermMonoid, GenericGrowthGroup(ZZ), QQ)._repr_()
'TermWithCoefficient-Monoid Generic(ZZ) with coefficients in Rational Field'
'TermWithCoefficient Monoid Generic(ZZ) with coefficients in Rational Field'
sage: TermWithCoefficientMonoid(TermMonoid, GrowthGroup('x^ZZ'), QQ)._repr_()
'TermWithCoefficient-Monoid x^ZZ with coefficients in Rational Field'
'TermWithCoefficient Monoid x^ZZ with coefficients in Rational Field'
"""
return 'TermWithCoefficient-Monoid %s with coefficients in %s' % \
return 'TermWithCoefficient Monoid %s with coefficients in %s' % \
(self.growth_group._repr_short_(), self.coefficient_ring)

def _validate_coefficient_or_error_(self, kwds_construction):
Expand Down Expand Up @@ -4552,7 +4552,7 @@ class TermMonoidFactory(UniqueRepresentation, UniqueFactory):
Exact Term Monoid x^ZZ with coefficients in Rational Field
sage: from sage.rings.asymptotic.term_monoid import GenericTermMonoid
sage: TermMonoid(GenericTermMonoid(TermMonoid, G, ZZ), asymptotic_ring=R)
GenericTerm-Monoid x^ZZ with (implicit) coefficients in Rational Field
GenericTerm Monoid x^ZZ with (implicit) coefficients in Rational Field
::
Expand Down

0 comments on commit f7c1823

Please sign in to comment.