Skip to content

Commit 7471239

Browse files
committed
Apply suggestions
1 parent bcd61e5 commit 7471239

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

src/sage/rings/fraction_field.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,18 @@ def _convert_from_finite_precision_laurent_series(self, x):
575575
Uses the algorithm described in `<https://mathoverflow.net/a/14874>`_.
576576
This may be changed to use Berlekamp--Massey algorithm or something else
577577
to compute Padé approximant in the future.
578+
579+
TESTS::
580+
581+
sage: F = QQ['x'].fraction_field()
582+
sage: R = LaurentSeriesRing(QQ, 'x')
583+
sage: f = ~R(x^2 + x + 3); f
584+
1/3 - 1/9*x - 2/27*x^2 + 5/81*x^3 + ... + O(x^20)
585+
sage: F._convert_from_finite_precision_laurent_series(f)
586+
1/(x^2 + x + 3)
578587
"""
579-
integral_part, fractional_part = self(x.truncate(1)), x.truncate_neg(1)
588+
integral_part = self(x.truncate(1))
589+
fractional_part = x.truncate_neg(1)
580590
if fractional_part.is_zero():
581591
return integral_part
582592
return integral_part + ~self._convert_from_finite_precision_laurent_series(~fractional_part)
@@ -678,7 +688,7 @@ def _element_constructor_(self, x, y=None, coerce=True):
678688
sage: F(x)
679689
-1/2/(a^2 + a)
680690
681-
Conversion from power series to rational function field truncates, but is deprecated::
691+
Conversion from power series to rational function field gives an approximation::
682692
683693
sage: F.<x> = Frac(QQ['x'])
684694
sage: R.<x> = QQ[[]]
@@ -687,8 +697,15 @@ def _element_constructor_(self, x, y=None, coerce=True):
687697
Power Series Ring in x over Rational Field
688698
sage: F(f)
689699
doctest:warning...
690-
DeprecationWarning: Conversion from power series to rational function field is deprecated, use .truncate() instead
700+
DeprecationWarning: Previously conversion from power series to rational function field truncates
701+
instead of gives an approximation. Use .truncate() to recover the old behavior
691702
See https://github.com/sagemath/sage/issues/39485 for details.
703+
1/(x + 1)
704+
705+
Previously, the power series was truncated. To recover the old behavior, use
706+
:meth:`~sage.rings.power_series_ring_element.PowerSeries.truncate`::
707+
708+
sage: F(f.truncate())
692709
-x^19 + x^18 - x^17 + x^16 - x^15 + x^14 - x^13 + x^12 - x^11 + x^10 - x^9 + x^8 - x^7 + x^6 - x^5 + x^4 - x^3 + x^2 - x + 1
693710
694711
Conversion from Laurent series to rational function field gives an approximation::
@@ -716,12 +733,14 @@ def _element_constructor_(self, x, y=None, coerce=True):
716733
717734
sage: K.<x> = FunctionField(QQ)
718735
sage: R.<x> = QQ[[]]
719-
sage: f = 1/(x+1)
736+
sage: f = 1/(x+1); f.parent()
737+
Power Series Ring in x over Rational Field
720738
sage: K(f)
721739
doctest:warning...
722-
DeprecationWarning: Conversion from power series to rational function field is deprecated, use .truncate() instead
740+
DeprecationWarning: Previously conversion from power series to rational function field truncates
741+
instead of gives an approximation. Use .truncate() to recover the old behavior
723742
See https://github.com/sagemath/sage/issues/39485 for details.
724-
-x^19 + x^18 - x^17 + x^16 - x^15 + x^14 - x^13 + x^12 - x^11 + x^10 - x^9 + x^8 - x^7 + x^6 - x^5 + x^4 - x^3 + x^2 - x + 1
743+
1/(x + 1)
725744
sage: f = Frac(R)(1/(x+1))
726745
sage: K(f)
727746
1/(x + 1)
@@ -742,8 +761,9 @@ def _element_constructor_(self, x, y=None, coerce=True):
742761
from sage.misc.superseded import deprecation
743762
deprecation(
744763
39485,
745-
"Conversion from power series to rational function field is deprecated, use .truncate() instead",
746-
)
764+
"Previously conversion from power series to rational function field truncates "
765+
"instead of gives an approximation. Use .truncate() to recover the old behavior")
766+
x = x.laurent_series()
747767
if isinstance(x, LaurentSeries):
748768
from sage.rings.infinity import infinity
749769
if x.prec() == infinity:

0 commit comments

Comments
 (0)