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 Sep 5, 2023
1 parent 534ba60 commit e985124
Show file tree
Hide file tree
Showing 3 changed files with 99 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 @@ -186,7 +186,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 @@ -243,7 +243,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 @@ -332,7 +332,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 @@ -433,7 +433,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 @@ -659,7 +659,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 @@ -738,7 +738,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 @@ -869,9 +869,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 @@ -1578,7 +1578,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 @@ -1596,6 +1596,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 @@ -1644,7 +1652,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 @@ -2236,6 +2244,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 @@ -2322,7 +2335,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 @@ -2355,7 +2368,7 @@ class Stream_rmul(Stream_scalar):
INPUT:
- ``series`` -- a :class:`Stream`
- ``scalar`` -- a non-zero scalar
- ``scalar`` -- a non-zero, non-one scalar
EXAMPLES::
Expand Down Expand Up @@ -2397,7 +2410,7 @@ class Stream_lmul(Stream_scalar):
INPUT:
- ``series`` -- a :class:`Stream`
- ``scalar`` -- a non-zero scalar
- ``scalar`` -- a non-zero, non-one scalar
EXAMPLES::
Expand Down Expand Up @@ -2504,7 +2517,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 @@ -2643,9 +2656,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 @@ -2660,7 +2673,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 @@ -2787,7 +2800,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 @@ -2833,7 +2846,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 @@ -2903,9 +2916,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 @@ -2925,7 +2938,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 @@ -3086,7 +3099,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 @@ -3132,7 +3145,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 @@ -3180,7 +3193,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 @@ -3293,7 +3306,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 e985124

Please sign in to comment.