Skip to content

Commit

Permalink
unify docstrings and uncontroversial doctests from sagemath#35480 and s…
Browse files Browse the repository at this point in the history
  • Loading branch information
mantepse authored and tscrim committed Aug 30, 2023
1 parent 8edf018 commit 5c59f33
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 43 deletions.
65 changes: 39 additions & 26 deletions src/sage/data_structures/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def __ne__(self, other):
def is_nonzero(self):
r"""
Return ``True`` if and only if this stream is known
to be nonzero.
to be non-zero.
The default implementation is ``False``.
Expand Down Expand Up @@ -242,7 +242,7 @@ def __init__(self, is_sparse, true_order):

def is_nonzero(self):
r"""
Return ``True`` if and only if the cache contains a nonzero element.
Return ``True`` if and only if the cache contains a non-zero element.
EXAMPLES::
Expand Down Expand Up @@ -331,7 +331,7 @@ def __setstate__(self, d):

def __getitem__(self, n):
"""
Return the `n`-th coefficient of ``self``.
Return the ``n``-th coefficient of ``self``.
INPUT:
Expand Down Expand Up @@ -432,7 +432,7 @@ def iterate_coefficients(self):
def order(self):
r"""
Return the order of ``self``, which is the minimum index ``n`` such
that ``self[n]`` is nonzero.
that ``self[n]`` is non-zero.
EXAMPLES::
Expand Down Expand Up @@ -658,7 +658,7 @@ def __init__(self, initial_coefficients, constant=None, degree=None, order=None)
# complicated otherwise
for i, v in enumerate(initial_coefficients):
if v:
# We have found the first nonzero coefficient
# We have found the first non-zero coefficient
order += i
initial_coefficients = initial_coefficients[i:]
if order + len(initial_coefficients) == self._degree:
Expand Down Expand Up @@ -737,7 +737,7 @@ def __getitem__(self, n):
def order(self):
r"""
Return the order of ``self``, which is the minimum index
``n`` such that ``self[n]`` is nonzero.
``n`` such that ``self[n]`` is non-zero.
EXAMPLES::
Expand Down Expand Up @@ -868,9 +868,9 @@ def __ne__(self, other):
def is_nonzero(self):
r"""
Return ``True`` if and only if this stream is known
to be nonzero.
to be non-zero.
An assumption of this class is that it is nonzero.
An assumption of this class is that it is non-zero.
EXAMPLES::
Expand Down Expand Up @@ -1580,7 +1580,7 @@ def get_coefficient(self, n):
def is_nonzero(self):
r"""
Return ``True`` if and only if this stream is known
to be nonzero.
to be non-zero.
EXAMPLES::
Expand All @@ -1598,6 +1598,14 @@ def is_nonzero(self):
return self._left.is_nonzero() and self._right.is_nonzero()


class Stream_cauchy_mul_commutative(Stream_cauchy_mul, Stream_binaryCommutative):
"""
Operator for multiplication of two coefficient streams using the
Cauchy product for commutative multiplication of coefficients.
"""
pass


class Stream_dirichlet_convolve(Stream_binary):
r"""
Operator for the Dirichlet convolution of two streams.
Expand Down Expand Up @@ -1646,7 +1654,7 @@ def _approximate_order(self):
or self._right._approximate_order <= 0):
raise ValueError("Dirichlet convolution is only defined for "
"coefficient streams with minimal index of "
"nonzero coefficient at least 1")
"non-zero coefficient at least 1")
return self._left._approximate_order * self._right._approximate_order

def get_coefficient(self, n):
Expand Down Expand Up @@ -2224,6 +2232,11 @@ class Stream_scalar(Stream_inexact):
Base class for operators multiplying a coefficient stream by a
scalar.
INPUT:
- ``series`` -- a :class:`Stream`
- ``scalar`` -- a non-zero, non-one scalar
.. TODO::
This does not inherit from :class:`Stream_unary`, because of
Expand Down Expand Up @@ -2310,7 +2323,7 @@ def __eq__(self, other):
def is_nonzero(self):
r"""
Return ``True`` if and only if this stream is known
to be nonzero.
to be non-zero.
EXAMPLES::
Expand Down Expand Up @@ -2343,7 +2356,7 @@ class Stream_rmul(Stream_scalar):
INPUT:
- ``series`` -- a :class:`Stream`
- ``scalar`` -- a scalar
- ``scalar`` -- a non-zero, non-one scalar
EXAMPLES::
Expand Down Expand Up @@ -2385,7 +2398,7 @@ class Stream_lmul(Stream_scalar):
INPUT:
- ``series`` -- a :class:`Stream`
- ``scalar`` -- a scalar
- ``scalar`` -- a non-zero, non-one scalar
EXAMPLES::
Expand Down Expand Up @@ -2492,7 +2505,7 @@ def get_coefficient(self, n):
def is_nonzero(self):
r"""
Return ``True`` if and only if this stream is known
to be nonzero.
to be non-zero.
EXAMPLES::
Expand Down Expand Up @@ -2630,9 +2643,9 @@ def iterate_coefficients(self):
def is_nonzero(self):
r"""
Return ``True`` if and only if this stream is known
to be nonzero.
to be non-zero.
An assumption of this class is that it is nonzero.
An assumption of this class is that it is non-zero.
EXAMPLES::
Expand All @@ -2647,7 +2660,7 @@ def is_nonzero(self):

class Stream_map_coefficients(Stream_inexact):
r"""
The stream with ``function`` applied to each nonzero coefficient
The stream with ``function`` applied to each non-zero coefficient
of ``series``.
INPUT:
Expand Down Expand Up @@ -2774,7 +2787,7 @@ def is_undefined(self):

class Stream_shift(Stream):
"""
Operator for shifting a nonzero, nonexact stream.
Operator for shifting a non-zero, non-exact stream.
Instances of this class share the cache with its input stream.
Expand Down Expand Up @@ -2820,7 +2833,7 @@ def _approximate_order(self):
def order(self):
r"""
Return the order of ``self``, which is the minimum index
``n`` such that ``self[n]`` is nonzero.
``n`` such that ``self[n]`` is non-zero.
EXAMPLES::
Expand Down Expand Up @@ -2889,9 +2902,9 @@ def __eq__(self, other):
def is_nonzero(self):
r"""
Return ``True`` if and only if this stream is known
to be nonzero.
to be non-zero.
An assumption of this class is that it is nonzero.
An assumption of this class is that it is non-zero.
EXAMPLES::
Expand All @@ -2911,7 +2924,7 @@ def is_undefined(self):

class Stream_truncated(Stream_inexact):
"""
Operator for shifting a nonzero, nonexact stream that has
Operator for shifting a non-zero, non-exact stream that has
been shifted below its minimal valuation.
Instances of this class share the cache with its input stream.
Expand Down Expand Up @@ -3072,7 +3085,7 @@ def __eq__(self, other):
def order(self):
"""
Return the order of ``self``, which is the minimum index ``n`` such
that ``self[n]`` is nonzero.
that ``self[n]`` is non-zero.
EXAMPLES::
Expand Down Expand Up @@ -3118,7 +3131,7 @@ def order(self):
def is_nonzero(self):
r"""
Return ``True`` if and only if this stream is known
to be nonzero.
to be non-zero.
EXAMPLES::
Expand Down Expand Up @@ -3166,7 +3179,7 @@ def is_undefined(self):

class Stream_derivative(Stream_inexact):
"""
Operator for taking derivatives of a stream.
Operator for taking derivatives of a non-exact stream.
INPUT:
Expand Down Expand Up @@ -3278,7 +3291,7 @@ def __eq__(self, other):
def is_nonzero(self):
r"""
Return ``True`` if and only if this stream is known
to be nonzero.
to be non-zero.
EXAMPLES::
Expand Down
Loading

0 comments on commit 5c59f33

Please sign in to comment.