Skip to content

Commit f72a51a

Browse files
committed
suggested changes, arigato !
1 parent dcc8c83 commit f72a51a

File tree

1 file changed

+29
-32
lines changed

1 file changed

+29
-32
lines changed

src/sage/combinat/free_prelie_algebra.py

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# the License, or (at your option) any later version.
1616
# https://www.gnu.org/licenses/
1717
# ****************************************************************************
18-
from copy import copy
1918
from itertools import product
2019

2120
from sage.categories.magmatic_algebras import MagmaticAlgebras
@@ -541,10 +540,8 @@ def corolla(self, x, y, n, N):
541540
INPUT:
542541
543542
- ``x``, ``y`` -- two elements
544-
545-
- ``n`` -- an integer, width of the corolla
546-
547-
- ``N`` -- an integer, truncation order (up to order ``N`` included)
543+
- ``n`` -- integer; width of the corolla
544+
- ``N`` -- integer; truncation order (up to order ``N`` included)
548545
549546
OUTPUT:
550547
@@ -577,11 +574,18 @@ def corolla(self, x, y, n, N):
577574
sage: A.corolla(a+b,a+b,2,4)
578575
B[a[a[], a[]]] + 2*B[a[a[], b[]]] + B[a[b[], b[]]] + B[b[a[], a[]]] +
579576
2*B[b[a[], b[]]] + B[b[b[], b[]]]
577+
578+
TESTS::
579+
580+
sage: A = algebras.FreePreLie(QQ,'ab')
581+
sage: a, b = A.gens()
582+
sage: A.corolla(a,A.zero(),2,2)
583+
0
580584
"""
581-
basering = self.base_ring()
582-
if x == self.zero() or y == self.zero():
585+
if not x or not y:
583586
return self.zero()
584587

588+
basering = self.base_ring()
585589
vx = x.valuation()
586590
vy = y.valuation()
587591
min_deg = vy * n + vx
@@ -613,9 +617,7 @@ def corolla(self, x, y, n, N):
613617
coef_y = basering.prod(mc[1] for mc in ly)
614618
arbres_y = [mc[0] for mc in ly]
615619
step += coef_y * self.sum(self(t)
616-
for t in corolla_gen(mx,
617-
arbres_y,
618-
labels))
620+
for t in corolla_gen(mx, arbres_y, labels))
619621
resu += coef_x * step
620622
return resu
621623

@@ -630,19 +632,13 @@ def group_product(self, x, y, n, N=10):
630632
631633
When considered with infinitely many terms and infinite precision,
632634
this is an analogue of the Baker-Campbell-Hausdorff formula: it
633-
defines an associative product on the free pre-Lie algebra.
635+
defines an associative product on the completed free pre-Lie algebra.
634636
635637
INPUT:
636638
637639
- ``x``, ``y`` -- two elements
638-
639-
- ``n`` -- an integer, the maximal width of corollas
640-
641-
- ``N`` -- an integer (optional, default: 10), truncation order
642-
643-
OUTPUT:
644-
645-
an element
640+
- ``n`` -- integer; the maximal width of corollas
641+
- ``N`` -- integer (default: 10); truncation order
646642
647643
EXAMPLES:
648644
@@ -858,6 +854,12 @@ def valuation(self):
858854
2
859855
sage: (a*b+a).valuation()
860856
1
857+
858+
TESTS::
859+
860+
sage: z = algebras.FreePreLie(QQ).zero()
861+
sage: z.valuation()
862+
+Infinity
861863
"""
862864
if self == self.parent().zero():
863865
return Infinity
@@ -1040,20 +1042,18 @@ def _repr_(self):
10401042

10411043
def tree_from_sortkey(ch, labels=True):
10421044
r"""
1043-
Transform a list of (valence, label) into a tree and a remainder.
1045+
Transform a list of ``(valence, label)`` into a tree and a remainder.
10441046
10451047
This is like an inverse of the ``sort_key`` method.
10461048
10471049
INPUT:
10481050
1049-
- ``ch`` -- a list of pairs (integer, label))
1050-
1051-
- ``labels`` -- optional (default ``True``)
1052-
whether to use labelled trees
1051+
- ``ch`` -- a list of pairs ``(integer, label)``
1052+
- ``labels`` -- (default ``True``) whether to use labelled trees
10531053
10541054
OUTPUT:
10551055
1056-
a pair (tree, remainder of the input)
1056+
a pair ``(tree, remainder of the input)``
10571057
10581058
EXAMPLES::
10591059
@@ -1100,11 +1100,8 @@ def corolla_gen(tx, list_ty, labels=True):
11001100
11011101
INPUT:
11021102
1103-
one tree ``tx``, a list of trees ``list_ty``
1104-
1105-
OUTPUT:
1106-
1107-
trees
1103+
- ``tx`` -- a tree
1104+
- ``list_ty`` -- a list of trees
11081105
11091106
EXAMPLES::
11101107
@@ -1130,8 +1127,8 @@ def corolla_gen(tx, list_ty, labels=True):
11301127
zx = tx.sort_key()
11311128
nx = len(zx)
11321129
liste_zy = [t.sort_key() for t in list_ty]
1133-
for list_pos in product(*[list(range(nx))] * n):
1134-
new_zx = copy(zx)
1130+
for list_pos in product(range(nx), repeat=n):
1131+
new_zx = tuple(zx)
11351132
data = zip(list_pos, liste_zy)
11361133
sorted_data = sorted(data, reverse=True)
11371134
for pos_t in sorted_data:

0 commit comments

Comments
 (0)