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

Commit

Permalink
fix invert
Browse files Browse the repository at this point in the history
  • Loading branch information
mantepse committed Aug 10, 2021
1 parent 883a01e commit 7c9a5dd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/sage/rings/lazy_laurent_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,14 @@ def __invert__(self):
sage: ~z
z^-1
TESTS::
sage: L.<x> = LazyLaurentSeriesRing(QQ)
sage: g = L([2], valuation=-1, constant=1); g
2*x^-1 + 1 + x + x^2 + O(x^3)
sage: g*g^-1
1 + O(x^7)
"""
P = self.parent()
coeff_stream = self._coeff_stream
Expand All @@ -1121,14 +1129,16 @@ def __invert__(self):
coeff_stream = CoefficientStream_exact((i, -i), P._sparse,
valuation=v, constant=c)
return P.element_class(P, coeff_stream)
if len(initial_coefficients) == 1:
if len(initial_coefficients) == 1 and not coeff_stream._constant:
i = ~initial_coefficients[0]
v = -coeff_stream.valuation()
c = P._coeff_ring.zero()
coeff_stream = CoefficientStream_exact((i,), P._sparse,
valuation=v, constant=c)
return P.element_class(P, coeff_stream)
if len(initial_coefficients) == 2 and not (initial_coefficients[0] + initial_coefficients[1]):
if (len(initial_coefficients) == 2
and not (initial_coefficients[0] + initial_coefficients[1])
and not coeff_stream._constant):
v = -coeff_stream.valuation()
c = ~initial_coefficients[0]
coeff_stream = CoefficientStream_exact((), P._sparse,
Expand Down

0 comments on commit 7c9a5dd

Please sign in to comment.