Skip to content

Commit 238de86

Browse files
author
Release Manager
committed
sagemathgh-39365: Allow coercion from Frac(QQ[x]) to LaurentSeriesRing(QQ) If `A` is a field then `self = LaurentSeriesRing(A)` is a field, by universal property of fraction field, a coercion `P.base() → self` can be uniquely extended to `P → self`. So this makes sense. As a side effect, this coercion allows the user to write things such as ```sage sage: R.<x> = QQ[] sage: 1/(x-1)+O(x^100) -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) ``` Another side effect: If the base ring is something like `Zmod(5)` or `QQ["x"].quotient(...)` then a primality/irreducibility check will be carried out. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39365 Reported by: user202729 Reviewer(s):
2 parents 81470bd + 9a90328 commit 238de86

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/sage/rings/laurent_series_ring.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,8 @@ def _coerce_map_from_(self, P):
676676
True
677677
sage: S.has_coerce_map_from(PolynomialRing(ZZ, 't'))
678678
True
679+
sage: S.has_coerce_map_from(Frac(PolynomialRing(ZZ, 't')))
680+
False
679681
sage: S.has_coerce_map_from(LaurentPolynomialRing(ZZ, 't'))
680682
True
681683
sage: S.has_coerce_map_from(PowerSeriesRing(ZZ, 't'))
@@ -698,6 +700,12 @@ def _coerce_map_from_(self, P):
698700
sage: S.has_coerce_map_from(LaurentSeriesRing(QQ, 't'))
699701
False
700702
703+
sage: T.<t> = LaurentSeriesRing(QQ)
704+
sage: T.has_coerce_map_from(QQ['t'])
705+
True
706+
sage: T.has_coerce_map_from(Frac(QQ['t']))
707+
True
708+
701709
sage: R.<t> = LaurentSeriesRing(QQ['x'])
702710
sage: R.has_coerce_map_from(QQ[['t']])
703711
True
@@ -714,7 +722,10 @@ def _coerce_map_from_(self, P):
714722
sage: R.has_coerce_map_from(LazyLaurentSeriesRing(ZZ['x'], 't'))
715723
True
716724
"""
725+
from sage.rings.fraction_field import FractionField_generic
717726
A = self.base_ring()
727+
if isinstance(P, FractionField_generic) and A.is_field():
728+
return self.has_coerce_map_from(P.base())
718729
if (isinstance(P, (LaurentSeriesRing, LazyLaurentSeriesRing,
719730
LaurentPolynomialRing_generic,
720731
PowerSeriesRing_generic, LazyPowerSeriesRing,

0 commit comments

Comments
 (0)