Skip to content

Commit 34d865f

Browse files
committed
reviewer's suggestions about docstring formatting and one list comprehension
1 parent bc9692d commit 34d865f

File tree

3 files changed

+30
-18
lines changed

3 files changed

+30
-18
lines changed

src/sage/data_structures/stream.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,7 @@ class CoefficientRing(UniqueRepresentation, FractionField_generic):
14021402
"""
14031403
def __init__(self, base_ring):
14041404
"""
1405+
Initialize ``self``.
14051406
14061407
EXAMPLES::
14071408
@@ -1919,8 +1920,8 @@ def _subs_in_caches(self, var, val):
19191920
19201921
INPUT:
19211922
1922-
- ``var``, a variable in ``self._P``
1923-
- ``val``, the value that should replace the variable
1923+
- ``var`` -- a variable in ``self._P``
1924+
- ``val`` -- the value that should replace the variable
19241925
19251926
EXAMPLES::
19261927

src/sage/rings/lazy_series_ring.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -667,14 +667,12 @@ def _terms_of_degree(self, n, R):
667667
Return the list of terms occurring in a coefficient of degree
668668
``n`` such that coefficients are in the ring ``R``.
669669
670-
If ``self`` is a univariate Laurent, power, or Dirichlet
671-
series, this is the list containing the one of the base ring.
672-
673-
If ``self`` is a multivariate power series, this is the list
674-
of monomials of total degree ``n``.
675-
676-
If ``self`` is a lazy symmetric function, this is the list
677-
of basis elements of total degree ``n``.
670+
For example, if ``self`` is a univariate Laurent, power, or
671+
Dirichlet series, this is the list containing the one of the
672+
base ring. If ``self`` is a multivariate power series, this
673+
is the list of monomials of total degree ``n``. If ``self``
674+
is a lazy symmetric function, this is the list of basis
675+
elements of total degree ``n``.
678676
679677
EXAMPLES::
680678
@@ -3292,12 +3290,11 @@ def _terms_of_degree(self, n, R):
32923290
B = B.change_ring(R)
32933291
if self._arity == 1:
32943292
return list(B.homogeneous_component_basis(n))
3295-
l = []
3296-
for c in IntegerVectors(n, self._arity):
3297-
for m in cartesian_product_iterator([F.homogeneous_component_basis(p)
3298-
for F, p in zip(B.tensor_factors(), c)]):
3299-
l.append(tensor(m))
3300-
return l
3293+
3294+
return [tensor(m)
3295+
for c in IntegerVectors(n, self._arity)
3296+
for m in cartesian_product_iterator([F.homogeneous_component_basis(p)
3297+
for F, p in zip(B.tensor_factors(), c)])]
33013298

33023299
def _element_constructor_(self, x=None, valuation=None, degree=None, constant=None, check=True):
33033300
r"""

src/sage/rings/polynomial/multi_polynomial_sequence.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def PolynomialSequence(arg1, arg2=None, immutable=False, cr=False, cr_str=None):
273273
274274
TESTS:
275275
276-
A PolynomialSequence can exist with elements in an infinite field of
276+
A ``PolynomialSequence`` can exist with elements in an infinite field of
277277
characteristic 2 (see :issue:`19452`)::
278278
279279
sage: from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence
@@ -283,7 +283,7 @@ def PolynomialSequence(arg1, arg2=None, immutable=False, cr=False, cr_str=None):
283283
sage: PolynomialSequence([0], R)
284284
[0]
285285
286-
A PolynomialSequence can be created from an iterator (see :issue:`25989`)::
286+
A ``PolynomialSequence`` can be created from an iterator (see :issue:`25989`)::
287287
288288
sage: R.<x,y,z> = QQ[]
289289
sage: PolynomialSequence(iter(R.gens()))
@@ -292,6 +292,20 @@ def PolynomialSequence(arg1, arg2=None, immutable=False, cr=False, cr_str=None):
292292
[x, y, z]
293293
sage: PolynomialSequence(iter([(x,y), (z,)]), R)
294294
[x, y, z]
295+
296+
A ``PolynomialSequence`` can be created from elements of an
297+
``InfinitePolynomialRing``::
298+
299+
sage: R.<a> = InfinitePolynomialRing(QQ)
300+
sage: s = PolynomialSequence([a[i]-a[i+1] for i in range(3)])
301+
sage: s
302+
[-a_1 + a_0, -a_2 + a_1, -a_3 + a_2]
303+
sage: s.coefficients_monomials()
304+
(
305+
[ 0 0 -1 1]
306+
[ 0 -1 1 0]
307+
[-1 1 0 0], (a_3, a_2, a_1, a_0)
308+
)
295309
"""
296310
from sage.structure.element import Matrix
297311
try:

0 commit comments

Comments
 (0)