|
57 | 57 | sage: f
|
58 | 58 | 1 + z + 2*z^2 + 3*z^3 + 5*z^4 + 8*z^5 + 13*z^6 + O(z^7)
|
59 | 59 | sage: f^-1
|
60 |
| - 1 - z - z^2 + O(z^7) |
| 60 | + 1 - z - z^2 |
61 | 61 | sage: f + f^-1
|
62 | 62 | 2 + z^2 + 3*z^3 + 5*z^4 + 8*z^5 + 13*z^6 + O(z^7)
|
63 | 63 | sage: g = (f + f^-1)*(f - f^-1); g
|
@@ -3256,10 +3256,20 @@ def __invert__(self):
|
3256 | 3256 | Traceback (most recent call last):
|
3257 | 3257 | ...
|
3258 | 3258 | ZeroDivisionError: cannot divide by a series of positive valuation
|
| 3259 | +
|
| 3260 | + Check that :issue:`36253` is fixed:: |
| 3261 | +
|
| 3262 | + sage: f = L(lambda n: n) |
| 3263 | + sage: ~f |
| 3264 | + Traceback (most recent call last): |
| 3265 | + ... |
| 3266 | + ZeroDivisionError: cannot divide by a series of positive valuation |
3259 | 3267 | """
|
3260 | 3268 | P = self.parent()
|
3261 | 3269 | coeff_stream = self._coeff_stream
|
3262 |
| - if P._minimal_valuation is not None and coeff_stream._approximate_order > 0: |
| 3270 | + if (P._minimal_valuation is not None |
| 3271 | + and (coeff_stream._approximate_order > 0 |
| 3272 | + or not coeff_stream.is_uninitialized() and not coeff_stream[0])): |
3263 | 3273 | raise ZeroDivisionError("cannot divide by a series of positive valuation")
|
3264 | 3274 |
|
3265 | 3275 | # the inverse is exact if and only if coeff_stream corresponds to one of
|
@@ -3411,9 +3421,11 @@ def _div_(self, other):
|
3411 | 3421 | sage: 1 / f
|
3412 | 3422 | Traceback (most recent call last):
|
3413 | 3423 | ...
|
3414 |
| - ZeroDivisionError: cannot divide by 0 |
| 3424 | + ZeroDivisionError: cannot divide by a series of positive valuation |
3415 | 3425 | sage: L.options._reset()
|
3416 | 3426 | """
|
| 3427 | + if self.is_one(): |
| 3428 | + return ~other |
3417 | 3429 | if not other:
|
3418 | 3430 | raise ZeroDivisionError("cannot divide by 0")
|
3419 | 3431 |
|
@@ -4351,6 +4363,7 @@ def revert(self):
|
4351 | 4363 | R = P.base_ring()
|
4352 | 4364 | # we cannot assume that the last initial coefficient
|
4353 | 4365 | # and the constant differ, see stream.Stream_exact
|
| 4366 | + # TODO: provide example or remove this claim |
4354 | 4367 | if (coeff_stream._degree == 1 + len(coeff_stream._initial_coefficients)
|
4355 | 4368 | and coeff_stream._constant == -R.one()
|
4356 | 4369 | and all(c == -R.one() for c in coeff_stream._initial_coefficients)):
|
|
0 commit comments