-
Notifications
You must be signed in to change notification settings - Fork 33
Closed
Description
In the following routine:
python-flint/src/flint/types/fmpz_series.pyx
Lines 61 to 78 in c1ac8c9
| def __init__(self, val=None, prec=None): | |
| if prec is None: | |
| self._prec = getcap() | |
| else: | |
| self._prec = prec | |
| if self._prec < 0: | |
| self._prec = -1 | |
| if val is not None: | |
| if typecheck(val, fmpz_series): | |
| fmpz_poly_set(self.val, (<fmpz_series>val).val) | |
| self._prec = min((<fmpz_series>val)._prec, getcap()) | |
| elif typecheck(val, fmpz_poly): | |
| fmpz_poly_set(self.val, (<fmpz_poly>val).val) | |
| elif typecheck(val, list): | |
| fmpz_poly_set_list(self.val, val) | |
| else: | |
| fmpz_poly_set_list(self.val, [val]) | |
| fmpz_poly_truncate(self.val, max(0, self._prec)) |
When setting the precision for a new series, the code currently compares the given series’s precision with the global cap. However, for correctness, it should compare it with self.prec (i.e., the already processed precision of the target object).
>>> from flint import fmpz_series
>>> x = fmpz_series([0,1], 5)
>>> fmpz_series(x, 4)
x + O(x^5)It should be x + O(x^4) but instead, due to comparing with gcap (which is 10), the precision logic behaves incorrectly, producing an unintended result.
Originally identified by @oscarbenjamin
Original comment: sympy/sympy#28109 (comment)
Metadata
Metadata
Assignees
Labels
No labels