Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Merge branch 'u/mantepse/categories_of_lazy_series' of trac.sagemath.…
Browse files Browse the repository at this point in the history
…org:sage into t/34552/more_testsuites_for_lazy_series_rings
  • Loading branch information
mantepse committed Sep 18, 2022
2 parents 60f0664 + fbccb39 commit b20eabf
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions src/sage/data_structures/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,13 @@ class Stream_exact(Stream):
of the first element which is known to be equal to ``constant``
- ``constant`` -- integer (default: 0); the coefficient
of every index larger than or equal to ``degree``
.. WARNING::
The convention for ``order`` is different to the one in
:class:`sage.rings.lazy_series_ring.LazySeriesRing`, where
the input is shifted to have the prescribed order.
"""
def __init__(self, initial_coefficients, is_sparse, constant=None, degree=None, order=None):
"""
Expand All @@ -533,18 +540,44 @@ def __init__(self, initial_coefficients, is_sparse, constant=None, degree=None,
Traceback (most recent call last):
...
AssertionError: Stream_exact should only be used for non-zero streams
sage: s = Stream_exact([0, 0, 1, 0, 0], False)
sage: s._initial_coefficients, s._true_order, s._degree
((1,), 2, 3)
sage: s = Stream_exact([0, 0, 1, 0, 0], False, constant=0)
sage: s._initial_coefficients, s._true_order, s._degree
((1,), 2, 3)
sage: s = Stream_exact([0, 0, 1, 0, 0], False, constant=0, degree=10)
sage: s._initial_coefficients, s._true_order, s._degree
((1,), 2, 3)
sage: s = Stream_exact([0, 0, 1, 0, 0], False, constant=1)
sage: s._initial_coefficients, s._true_order, s._degree
((1,), 2, 5)
sage: s = Stream_exact([0, 0, 1, 2, 1, 1], False, constant=1)
sage: s._initial_coefficients, s._true_order, s._degree
((1, 2), 2, 4)
sage: s = Stream_exact([0, 0, 1, 2, 1, 1], False, constant=1, order=-2)
sage: s._initial_coefficients, s._true_order, s._degree
((1, 2), 0, 2)
"""
if constant is None:
self._constant = ZZ.zero()
else:
self._constant = constant

if order is None:
order = 0
if degree is None:
if (degree is None
or (not self._constant
and degree > order + len(initial_coefficients))):
self._degree = order + len(initial_coefficients)
else:
self._degree = degree

assert order + len(initial_coefficients) <= self._degree

# we remove leading and trailing zeros from
Expand All @@ -562,7 +595,7 @@ def __init__(self, initial_coefficients, is_sparse, constant=None, degree=None,
initial_coefficients = initial_coefficients[i:]
if order + len(initial_coefficients) == self._degree:
for j, w in enumerate(reversed(initial_coefficients)):
if w != constant:
if w != self._constant:
break
initial_coefficients.pop()
self._degree -= 1
Expand Down

0 comments on commit b20eabf

Please sign in to comment.