From 2be305d38f40742d93f4edb96d267c229a56f929 Mon Sep 17 00:00:00 2001 From: tejasvicsr1 Date: Wed, 4 Aug 2021 02:45:33 +0530 Subject: [PATCH] Small error fixed, typos fixed. --- .../data_structures/coefficient_stream.py | 10 +++--- src/sage/rings/lazy_laurent_series.py | 32 ++++++++++--------- src/sage/rings/lazy_laurent_series_ring.py | 8 ++--- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/sage/data_structures/coefficient_stream.py b/src/sage/data_structures/coefficient_stream.py index a6de8618d11..1351ad3c814 100644 --- a/src/sage/data_structures/coefficient_stream.py +++ b/src/sage/data_structures/coefficient_stream.py @@ -1047,7 +1047,7 @@ class CoefficientStream_add(CoefficientStream_binary_commutative): """ def __init__(self, left, right): """ - Initalize. + Initialize. TESTS:: @@ -1127,7 +1127,7 @@ class CoefficientStream_sub(CoefficientStream_binary): def __init__(self, left, right): """ - Initalize ``self``. + initialize ``self``. TESTS:: @@ -1208,7 +1208,7 @@ class CoefficientStream_cauchy_product(CoefficientStream_binary_commutative): """ def __init__(self, left, right): """ - Initalize ``self``. + initialize ``self``. TESTS:: @@ -1300,7 +1300,7 @@ class CoefficientStream_div(CoefficientStream_binary): def __init__(self, left, right): """ - Initalize ``self``. + initialize ``self``. TESTS:: @@ -1398,7 +1398,7 @@ class CoefficientStream_composition(CoefficientStream_binary): """ def __init__(self, f, g): """ - Initalize ``self``. + initialize ``self``. TESTS:: diff --git a/src/sage/rings/lazy_laurent_series.py b/src/sage/rings/lazy_laurent_series.py index f171086d1e9..eb94809e2af 100644 --- a/src/sage/rings/lazy_laurent_series.py +++ b/src/sage/rings/lazy_laurent_series.py @@ -211,11 +211,11 @@ def map_coefficients(self, func, ring=None): P = self.parent() coeff_stream = self._coeff_stream if isinstance(coeff_stream, CoefficientStream_exact): - inital_coefficients = [func(i) if i else 0 for i in coeff_stream._initial_coefficients] + initial_coefficients = [func(i) if i else 0 for i in coeff_stream._initial_coefficients] c = func(coeff_stream._constant) if coeff_stream._constant else 0 - if not any(inital_coefficients) and not c: + if not any(initial_coefficients) and not c: return P.zero() - coeff_stream = CoefficientStream_exact(inital_coefficients, self._coeff_stream._is_sparse, + coeff_stream = CoefficientStream_exact(initial_coefficients, self._coeff_stream._is_sparse, valuation=coeff_stream._approximate_valuation, degree=coeff_stream._degree, constant=c) @@ -265,8 +265,8 @@ def truncate(self, d): """ P = self.parent() coeff_stream = self._coeff_stream - inital_coefficients = [coeff_stream[i] for i in range(coeff_stream._approximate_valuation, d)] - return P.element_class(P, CoefficientStream_exact(inital_coefficients, P._sparse, + initial_coefficients = [coeff_stream[i] for i in range(coeff_stream._approximate_valuation, d)] + return P.element_class(P, CoefficientStream_exact(initial_coefficients, P._sparse, valuation=coeff_stream._approximate_valuation)) def prec(self): @@ -1116,7 +1116,9 @@ def __call__(self, g): True sage: f = L(lambda n: n, 0) sage: f(g) - 0 + ... + Traceback (most recent call last): + ... + ValueError: can only compose with a positive valuation series We cannot compose if `g` has a negative valuation:: @@ -1162,8 +1164,8 @@ def __call__(self, g): g_poly = R(sum([g._coeff_stream[i] * z**i for i in range(g._coeff_stream._approximate_valuation, g._coeff_stream._degree)])) ret = poly(g_poly) if ret.parent() is R: - inital_coefficients = [ret[i] for i in range(ret.valuation(), ret.degree() + 1)] - return P.element_class(P, CoefficientStream_exact(inital_coefficients, self._coeff_stream._is_sparse, valuation=ret.valuation())) + initial_coefficients = [ret[i] for i in range(ret.valuation(), ret.degree() + 1)] + return P.element_class(P, CoefficientStream_exact(initial_coefficients, self._coeff_stream._is_sparse, valuation=ret.valuation())) except TypeError: # the result is not a Laurent polynomial pass @@ -1194,7 +1196,7 @@ def __call__(self, g): raise NotImplementedError("can only compose with a lazy Laurent series") # Perhaps we just don't yet know if the valuation is positive if g._coeff_stream._approximate_valuation <= 0: - if any(g._coeff_stream[i] for i in range(min(self._coeff_stream._approximate_valuation, 0), 1)): + if any(g._coeff_stream[i] for i in range(g._coeff_stream._approximate_valuation, 1)): raise ValueError("can only compose with a positive valuation series") g._coeff_stream._approximate_valuation = 1 @@ -1259,8 +1261,8 @@ def _mul_(self, other): pr = R(sum([right[i] * z**i for i in range(right._approximate_valuation, right._degree)])) p = pl * pr c = left._constant - inital_coefficients = [p[i] for i in range(p.valuation(), p.degree() + 1)] - return P.element_class(P, CoefficientStream_exact(inital_coefficients, P._sparse, valuation=p.valuation(), constant=c)) + initial_coefficients = [p[i] for i in range(p.valuation(), p.degree() + 1)] + return P.element_class(P, CoefficientStream_exact(initial_coefficients, P._sparse, valuation=p.valuation(), constant=c)) elif isinstance(right, CoefficientStream_exact): if not right._constant: pr = R(sum([right[i] * z**i for i in range(right._approximate_valuation, right._degree)])) @@ -1340,8 +1342,8 @@ def _div_(self, other): ret = pl / pr try: ret = P._laurent_poly_ring(ret) - inital_coefficients = [ret[i] for i in range(ret.valuation(), ret.degree() + 1)] - return P.element_class(P, CoefficientStream_exact(inital_coefficients, P._sparse, valuation=ret.valuation(), constant=left._constant)) + initial_coefficients = [ret[i] for i in range(ret.valuation(), ret.degree() + 1)] + return P.element_class(P, CoefficientStream_exact(initial_coefficients, P._sparse, valuation=ret.valuation(), constant=left._constant)) except (TypeError, ValueError): # We cannot divide the polynomials, so the result must be a series pass @@ -1388,8 +1390,8 @@ def __invert__(self): poly = R(sum([self._coeff_stream[i] * z**i for i in range(self._coeff_stream._approximate_valuation, self._coeff_stream._degree)])) if poly == R.gen(): ret = 1 / poly - inital_coefficients = [ret[i] for i in range(ret.valuation(), ret.degree() + 1)] - return P.element_class(P, CoefficientStream_exact(inital_coefficients, P._sparse, valuation=ret.valuation(), constant=self._coeff_stream._constant)) + initial_coefficients = [ret[i] for i in range(ret.valuation(), ret.degree() + 1)] + return P.element_class(P, CoefficientStream_exact(initial_coefficients, P._sparse, valuation=ret.valuation(), constant=self._coeff_stream._constant)) # (f^-1)^-1 = f if isinstance(self._coeff_stream, CoefficientStream_cauchy_inverse): return P.element_class(P, self._coeff_stream._series) diff --git a/src/sage/rings/lazy_laurent_series_ring.py b/src/sage/rings/lazy_laurent_series_ring.py index 03c70343f84..0d9a0b42fd0 100644 --- a/src/sage/rings/lazy_laurent_series_ring.py +++ b/src/sage/rings/lazy_laurent_series_ring.py @@ -226,8 +226,8 @@ def _coerce_map_from_(self, S): R = self._laurent_poly_ring if R.has_coerce_map_from(S): def make_series_from(poly): - inital_coefficients = [poly[i] for i in range(poly.valuation(), poly.degree() + 1)] - coeff_stream = CoefficientStream_exact(inital_coefficients, self._sparse, valuation=poly.valuation()) + initial_coefficients = [poly[i] for i in range(poly.valuation(), poly.degree() + 1)] + coeff_stream = CoefficientStream_exact(initial_coefficients, self._sparse, valuation=poly.valuation()) return self.element_class(self, coeff_stream) return SetMorphism(Hom(S, self, Sets()), make_series_from) @@ -352,8 +352,8 @@ def _element_constructor_(self, x=None, valuation=None, constant=None, degree=No if x == R.zero(): coeff_stream = CoefficientStream_exact([x], self._sparse, valuation=degree-1, constant=constant) return self.element_class(self, coeff_stream) - inital_coefficients = [x[i] for i in range(x.valuation(), x.degree() + 1)] - coeff_stream = CoefficientStream_exact(inital_coefficients, self._sparse, valuation=x.valuation(), constant=constant, degree=degree) + initial_coefficients = [x[i] for i in range(x.valuation(), x.degree() + 1)] + coeff_stream = CoefficientStream_exact(initial_coefficients, self._sparse, valuation=x.valuation(), constant=constant, degree=degree) return self.element_class(self, coeff_stream) if isinstance(x, LazyLaurentSeries): if x._coeff_stream._is_sparse is self._sparse: