Skip to content

Commit d763d66

Browse files
committed
Trac #32215: full coverage of _element_constructor_
1 parent 51e035f commit d763d66

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/sage/rings/asymptotic/term_monoid.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,8 +1784,9 @@ def _element_constructor_(self, data, *args, **kwds):
17841784
17851785
TESTS::
17861786
1787-
sage: O_ZZ = TermMonoid('O', G_ZZ, QQ)
1788-
sage: O_ZZ(x^11)
1787+
sage: G = GrowthGroup('x^ZZ')
1788+
sage: OT = TermMonoid('O', G, ZZ)
1789+
sage: OT(x^11)
17891790
O(x^11)
17901791
17911792
::
@@ -1809,6 +1810,30 @@ def _element_constructor_(self, data, *args, **kwds):
18091810
sage: T_log(log(x))
18101811
Term with coefficient 1 and growth log(x)
18111812
1813+
::
1814+
1815+
sage: OT(G.gen(), coefficient=5, growth=G.gen())
1816+
Traceback (most recent call last):
1817+
...
1818+
ValueError: Argument 'growth=x' is ambiguous.
1819+
sage: OT(SR(3*x), growth=G.gen())
1820+
Traceback (most recent call last):
1821+
...
1822+
ValueError: Argument 'growth=x' is ambiguous.
1823+
1824+
::
1825+
1826+
sage: OT(G.gen(), 4)
1827+
doctest:warning
1828+
...
1829+
DeprecationWarning: Passing 'coefficient' as a positional argument is deprecated;
1830+
specify it as keyword argument 'coefficient=...'.
1831+
See https://trac.sagemath.org/32215 for details.
1832+
O(x)
1833+
sage: OT(G.gen(), 4, coefficient=5)
1834+
Traceback (most recent call last):
1835+
...
1836+
ValueError: Argument 'coefficient=5' is ambiguous.
18121837
"""
18131838
if len(args) > 1:
18141839
raise TypeError(
@@ -1853,8 +1878,7 @@ def _element_constructor_(self, data, *args, **kwds):
18531878

18541879
if 'growth' in kwds:
18551880
raise ValueError(f"Argument 'growth={kwds['growth']}' is ambiguous.")
1856-
if 'coefficient' in kwds:
1857-
raise ValueError(f"Argument 'coefficient={kwds['coefficient']}' is ambiguous.")
1881+
18581882
return self.from_construction((None,
18591883
{'growth': growth,
18601884
'coefficient': coefficient}),

0 commit comments

Comments
 (0)