Skip to content

Commit 3613545

Browse files
author
Release Manager
committed
Trac #32215: Asymptotic Term Monoids: refactor element construction
In #31933 conversion fails. In order to fix this properly, a refactor of the conversion process seems the best solution. This ticket does this (without fixing the open issue on #31933 which will be a follow up). URL: https://trac.sagemath.org/32215 Reported by: dkrenn Ticket author(s): Daniel Krenn Reviewer(s): Benjamin Hackl
2 parents 493433c + 89ad9d2 commit 3613545

File tree

4 files changed

+675
-165
lines changed

4 files changed

+675
-165
lines changed

build/pkgs/configure/checksums.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
tarball=configure-VERSION.tar.gz
2-
sha1=766d040ff9b94c355e1e340ba2b4a7bc2fbc4a2f
3-
md5=154dee70c098f55a683291398591fee2
4-
cksum=1315912721
2+
sha1=fa7a6a287c18e8c4129ef5e7f098e716bd30f73f
3+
md5=a342ed4d433163a2dbb43f2202740575
4+
cksum=2901964880
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
42052ec4ff3edacd2c8d8df6a73ad5e63731d0f7
1+
1ed7c6033bc77e3dffbd60b0777d3b939a4226b4

src/sage/rings/asymptotic/asymptotic_ring.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def __init__(self, parent, summands, simplify=True, convert=True):
575575
sage: G = GrowthGroup('x^ZZ'); x = G.gen()
576576
sage: OT = TermMonoid('O', G, ZZ); ET = TermMonoid('exact', G, ZZ)
577577
sage: R = AsymptoticRing(G, ZZ)
578-
sage: lst = [ET(x, 1), ET(x^2, 2), OT(x^3), ET(x^4, 4)]
578+
sage: lst = [ET(x, coefficient=1), ET(x^2, coefficient=2), OT(x^3), ET(x^4, coefficient=4)]
579579
sage: expr = R(lst, simplify=False); expr # indirect doctest
580580
4*x^4 + O(x^3) + 2*x^2 + x
581581
sage: print(expr.summands.repr_full())
@@ -641,8 +641,10 @@ def __init__(self, parent, summands, simplify=True, convert=True):
641641
ValueError: Cannot include 1/2 with parent
642642
Exact Term Monoid x^QQ with coefficients in Rational Field in
643643
Asymptotic Ring <x^QQ> over Integer Ring
644-
> *previous* ValueError: 1/2 is not a coefficient in
645-
Exact Term Monoid x^QQ with coefficients in Integer Ring.
644+
> *previous* ValueError: Cannot create ExactTerm(1)
645+
since given coefficient 1/2 is not valid in
646+
Exact Term Monoid x^QQ with coefficients in Integer Ring.
647+
>> *previous* TypeError: no conversion of this rational to integer
646648
647649
Check :trac:`19921`::
648650
@@ -949,7 +951,7 @@ def _simplify_(self):
949951
sage: G = GrowthGroup('x^ZZ')
950952
sage: OT = TermMonoid('O', G, ZZ); ET = TermMonoid('exact', G, ZZ)
951953
sage: R = AsymptoticRing(G, ZZ)
952-
sage: lst = [ET(x, 1), ET(x^2, 2), OT(x^3), ET(x^4, 4)]
954+
sage: lst = [ET(x, coefficient=1), ET(x^2, coefficient=2), OT(x^3), ET(x^4, coefficient=4)]
953955
sage: expr = R(lst, simplify=False); expr # indirect doctest
954956
4*x^4 + O(x^3) + 2*x^2 + x
955957
sage: expr._simplify_(); expr
@@ -1079,7 +1081,9 @@ def monomial_coefficient(self, monomial):
10791081
ValueError: Cannot include n with parent Exact Term Monoid
10801082
n^QQ with coefficients in Rational Field in Asymptotic Ring
10811083
<m^QQ> over Rational Field
1082-
> *previous* ValueError: n is not in Growth Group m^QQ.
1084+
> *previous* ValueError: Growth n is not valid in
1085+
Exact Term Monoid m^QQ with coefficients in Rational Field.
1086+
>> *previous* ValueError: n is not in Growth Group m^QQ.
10831087
10841088
Only monomials are allowed::
10851089
@@ -3068,8 +3072,10 @@ def map_coefficients(self, f, new_coefficient_ring=None):
30683072
sage: a.map_coefficients(lambda c: 1/c)
30693073
Traceback (most recent call last):
30703074
...
3071-
ValueError: ... is not a coefficient in
3075+
ValueError: Cannot create ExactTerm(n^3) since
3076+
given coefficient 1/2 is not valid in
30723077
Exact Term Monoid n^ZZ with coefficients in Integer Ring.
3078+
> *previous* TypeError: no conversion of this rational to integer
30733079
"""
30743080
def mapping(term):
30753081
T = term.parent().change_parameter(
@@ -3078,7 +3084,7 @@ def mapping(term):
30783084
c = f(term.coefficient)
30793085
if c.is_zero():
30803086
return None
3081-
return T(term.growth, c)
3087+
return T(term.growth, coefficient=c)
30823088
else:
30833089
return T(term.growth)
30843090

@@ -3922,7 +3928,7 @@ def _element_constructor_(self, data, simplify=True, convert=True):
39223928
...
39233929
ValueError: Polynomial y is not in
39243930
Asymptotic Ring <x^ZZ> over Integer Ring
3925-
> *previous* ValueError: Growth y is not in
3931+
> *previous* ValueError: Growth y is not valid in
39263932
Exact Term Monoid x^ZZ with coefficients in Integer Ring.
39273933
>> *previous* ValueError: y is not in Growth Group x^ZZ.
39283934
@@ -3965,7 +3971,7 @@ def _element_constructor_(self, data, simplify=True, convert=True):
39653971
...
39663972
ValueError: Polynomial a + c is not in
39673973
Asymptotic Ring <a^ZZ * b^ZZ> over Rational Field
3968-
> *previous* ValueError: Growth c is not in
3974+
> *previous* ValueError: Growth c is not valid in
39693975
Exact Term Monoid a^ZZ * b^ZZ with coefficients in Rational Field.
39703976
>> *previous* ValueError: c is not in Growth Group a^ZZ * b^ZZ.
39713977
>...> *previous* ValueError: c is not in any of the factors
@@ -3983,7 +3989,9 @@ def _element_constructor_(self, data, simplify=True, convert=True):
39833989
ValueError: Cannot include m^3 with parent
39843990
Exact Term Monoid m^ZZ with coefficients in Integer Ring
39853991
in Asymptotic Ring <n^ZZ> over Rational Field
3986-
> *previous* ValueError: m^3 is not in Growth Group n^ZZ.
3992+
> *previous* ValueError: Growth m^3 is not valid in
3993+
Exact Term Monoid n^ZZ with coefficients in Rational Field.
3994+
>> *previous* ValueError: m^3 is not in Growth Group n^ZZ.
39873995
39883996
::
39893997
@@ -4539,7 +4547,7 @@ def create_summand(self, type, data=None, **kwds):
45394547
sage: R.create_summand('O', growth=42*x^2, coefficient=1)
45404548
Traceback (most recent call last):
45414549
...
4542-
ValueError: Growth 42*x^2 is not in O-Term Monoid x^ZZ with implicit coefficients in Integer Ring.
4550+
ValueError: Growth 42*x^2 is not valid in O-Term Monoid x^ZZ with implicit coefficients in Integer Ring.
45434551
> *previous* ValueError: 42*x^2 is not in Growth Group x^ZZ.
45444552
45454553
::

0 commit comments

Comments
 (0)