Skip to content

Commit 3f48052

Browse files
committed
Add test for the current situation
1 parent dc99dc8 commit 3f48052

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

src/sage/rings/fraction_field.py

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,61 @@ def _element_constructor_(self, x, y=None, coerce=True):
653653
sage: x = FF(elt)
654654
sage: F(x)
655655
-1/2/(a^2 + a)
656+
657+
Conversion from power series to rational function field truncates, but is deprecated::
658+
659+
sage: F.<x> = Frac(QQ['x'])
660+
sage: R.<x> = QQ[[]]
661+
sage: f = 1/(x+1)
662+
sage: f.parent()
663+
Power Series Ring in x over Rational Field
664+
sage: F(f)
665+
-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
666+
667+
Conversion from Laurent series to rational function field gives an approximation::
668+
669+
sage: F.<x> = Frac(QQ['x'])
670+
sage: R.<x> = QQ[[]]
671+
sage: f = Frac(R)(1/(x+1))
672+
sage: f.parent()
673+
Laurent Series Ring in x over Rational Field
674+
sage: F(f)
675+
Traceback (most recent call last):
676+
...
677+
TypeError: cannot convert 1 - x + x^2 - x^3 + x^4 - x^5 + x^6 - x^7 + x^8 - x^9 + x^10 - x^11 + x^12 - x^13 + x^14 - x^15 + x^16 - x^17 + x^18 - x^19 + O(x^20)/1 to an element of Fraction Field of Univariate Polynomial Ring in x over Rational Field
678+
sage: f = f.truncate(20); f # infinite precision
679+
1 - x + x^2 - x^3 + x^4 - x^5 + x^6 - x^7 + x^8 - x^9 + x^10 - x^11 + x^12 - x^13 + x^14 - x^15 + x^16 - x^17 + x^18 - x^19
680+
sage: f.parent()
681+
Laurent Series Ring in x over Rational Field
682+
sage: F(f)
683+
Traceback (most recent call last):
684+
...
685+
TypeError: cannot convert 1 - x + x^2 - x^3 + x^4 - x^5 + x^6 - x^7 + x^8 - x^9 + x^10 - x^11 + x^12 - x^13 + x^14 - x^15 + x^16 - x^17 + x^18 - x^19/1 to an element of Fraction Field of Univariate Polynomial Ring in x over Rational Field
686+
sage: f = 1/(x*(x+1))
687+
sage: f.parent()
688+
Laurent Series Ring in x over Rational Field
689+
sage: F(f)
690+
Traceback (most recent call last):
691+
...
692+
TypeError: cannot convert x^-1 - 1 + x - x^2 + x^3 - x^4 + x^5 - x^6 + x^7 - x^8 + x^9 - x^10 + x^11 - x^12 + x^13 - x^14 + x^15 - x^16 + x^17 - x^18 + O(x^19)/1 to an element of Fraction Field of Univariate Polynomial Ring in x over Rational Field
693+
694+
::
695+
696+
sage: K.<x> = FunctionField(QQ)
697+
sage: R.<x> = QQ[[]]
698+
sage: f = 1/(x+1)
699+
sage: K(f)
700+
-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
701+
sage: f = Frac(R)(1/(x+1))
702+
sage: K(f)
703+
Traceback (most recent call last):
704+
...
705+
TypeError: cannot convert 1 - x + x^2 - x^3 + x^4 - x^5 + x^6 - x^7 + x^8 - x^9 + x^10 - x^11 + x^12 - x^13 + x^14 - x^15 + x^16 - x^17 + x^18 - x^19 + O(x^20)/1 to an element of Fraction Field of Univariate Polynomial Ring in x over Rational Field
706+
sage: f = 1/(x*(x+1))
707+
sage: K(f)
708+
Traceback (most recent call last):
709+
...
710+
TypeError: cannot convert x^-1 - 1 + x - x^2 + x^3 - x^4 + x^5 - x^6 + x^7 - x^8 + x^9 - x^10 + x^11 - x^12 + x^13 - x^14 + x^15 - x^16 + x^17 - x^18 + O(x^19)/1 to an element of Fraction Field of Univariate Polynomial Ring in x over Rational Field
656711
"""
657712
if isinstance(x, (list, tuple)) and len(x) == 1:
658713
x = x[0]
@@ -664,8 +719,7 @@ def _element_constructor_(self, x, y=None, coerce=True):
664719
return self._element_class(self, x, ring_one, coerce=coerce)
665720
except (TypeError, ValueError):
666721
pass
667-
y = self._element_class(self, ring_one, ring_one,
668-
coerce=False, reduce=False)
722+
y = self.one()
669723
else:
670724
if parent(x) is self:
671725
y = self(y)

0 commit comments

Comments
 (0)