From 79da410606ff2f17f7a2c82b13abd0a735ec7c04 Mon Sep 17 00:00:00 2001 From: Travis Scrimshaw Date: Wed, 22 Mar 2023 11:35:26 +0900 Subject: [PATCH] Update due to changes in #35265. --- src/sage/data_structures/stream.py | 37 +++++------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/src/sage/data_structures/stream.py b/src/sage/data_structures/stream.py index a24e8490ff5..5d0ccf7e369 100644 --- a/src/sage/data_structures/stream.py +++ b/src/sage/data_structures/stream.py @@ -2880,33 +2880,6 @@ def __init__(self, series, shift, minimal_valuation): self._minimal_valuation = minimal_valuation self._approximate_order = minimal_valuation - @lazy_attribute - def _offset(self): - """ - Return the offset of a stream with a dense cache. - - EXAMPLES:: - - sage: from sage.data_structures.stream import Stream_function, Stream_truncated - sage: def fun(n): return 1 if ZZ(n).is_power_of(2) else 0 - sage: f = Stream_function(fun, False, 0) - sage: [f[i] for i in range(8)] - [0, 1, 1, 0, 1, 0, 0, 0] - sage: f._cache - [0, 1, 1, 0, 1, 0, 0, 0] - sage: s = Stream_truncated(f, -5, 0) - sage: s._offset - -5 - sage: [s[i] for i in range(10)] - [0, 0, 0, 1, 0, 0, 0, 0, 0, 0] - sage: s._cache - [0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0] - """ - # self[n] = self._cache[n-self._offset] - if self._is_sparse: - raise ValueError("_offset is only for dense streams") - return self._series._offset + self._shift - def __getitem__(self, n): """ Return the ``n``-th coefficient of ``self``. @@ -2997,7 +2970,7 @@ def order(self): n = self._approximate_order cache = self._series._cache while True: - if n-self._shift in cache: + if n - self._shift in cache: if cache[n-self._shift]: self._approximate_order = n self._true_order = True @@ -3005,6 +2978,7 @@ def order(self): elif self[n]: return n n += 1 + # dense case return super().order() def is_nonzero(self): @@ -3020,7 +2994,7 @@ def is_nonzero(self): sage: [f[i] for i in range(0, 4)] [0, 1, 1, 0] sage: f._cache - [0, 1, 1, 0] + [1, 1, 0] sage: s = Stream_truncated(f, -5, 0) sage: s.is_nonzero() False @@ -3033,7 +3007,7 @@ def is_nonzero(self): sage: [f[i] for i in range(0, 4)] [0, 1, 1, 0] sage: f._cache - {0: 0, 1: 1, 2: 1, 3: 0} + {1: 1, 2: 1, 3: 0} sage: s = Stream_truncated(f, -5, 0) sage: s.is_nonzero() False @@ -3044,7 +3018,8 @@ def is_nonzero(self): """ if self._is_sparse: return any(c for n, c in self._series._cache.items() if n + self._shift >= self._minimal_valuation) - start = self._approximate_order - self._offset + offset = self._series._approximate_order + self._shift + start = self._approximate_order - offset return any(self._series._cache[start:])