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

Commit

Permalink
Small error fixed, typos fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
tejasvicsr1 committed Aug 3, 2021
1 parent ee9d593 commit 2be305d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
10 changes: 5 additions & 5 deletions src/sage/data_structures/coefficient_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ class CoefficientStream_add(CoefficientStream_binary_commutative):
"""
def __init__(self, left, right):
"""
Initalize.
Initialize.
TESTS::
Expand Down Expand Up @@ -1127,7 +1127,7 @@ class CoefficientStream_sub(CoefficientStream_binary):

def __init__(self, left, right):
"""
Initalize ``self``.
initialize ``self``.
TESTS::
Expand Down Expand Up @@ -1208,7 +1208,7 @@ class CoefficientStream_cauchy_product(CoefficientStream_binary_commutative):
"""
def __init__(self, left, right):
"""
Initalize ``self``.
initialize ``self``.
TESTS::
Expand Down Expand Up @@ -1300,7 +1300,7 @@ class CoefficientStream_div(CoefficientStream_binary):

def __init__(self, left, right):
"""
Initalize ``self``.
initialize ``self``.
TESTS::
Expand Down Expand Up @@ -1398,7 +1398,7 @@ class CoefficientStream_composition(CoefficientStream_binary):
"""
def __init__(self, f, g):
"""
Initalize ``self``.
initialize ``self``.
TESTS::
Expand Down
32 changes: 17 additions & 15 deletions src/sage/rings/lazy_laurent_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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::
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)]))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/sage/rings/lazy_laurent_series_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 2be305d

Please sign in to comment.