Skip to content

Commit 2369cad

Browse files
author
Release Manager
committed
gh-39394: move methods into category of fields moving 3 methods from the auld `Field` class to the category of Fields. ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #39394 Reported by: Frédéric Chapoton Reviewer(s): Vincent Macri
2 parents 673f9a0 + 50b0b7d commit 2369cad

File tree

3 files changed

+55
-54
lines changed

3 files changed

+55
-54
lines changed

src/doc/en/thematic_tutorials/coercion_and_categories.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,15 @@ This base class provides a lot more methods than a general parent::
123123
'algebraic_closure',
124124
'an_embedding',
125125
'base_extend',
126-
'divides',
127126
'epsilon',
128127
'extension',
129128
'fraction_field',
130129
'gen',
131130
'gens',
132-
'integral_closure',
133131
'is_field',
134132
'ngens',
135133
'one',
136134
'order',
137-
'prime_subfield',
138135
'random_element',
139136
'zero',
140137
'zeta',

src/sage/categories/fields.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,61 @@ def is_integrally_closed(self) -> bool:
240240
"""
241241
return True
242242

243+
def integral_closure(self):
244+
"""
245+
Return this field, since fields are integrally closed in their
246+
fraction field.
247+
248+
EXAMPLES::
249+
250+
sage: QQ.integral_closure()
251+
Rational Field
252+
sage: Frac(ZZ['x,y']).integral_closure()
253+
Fraction Field of Multivariate Polynomial Ring in x, y
254+
over Integer Ring
255+
"""
256+
return self
257+
258+
def prime_subfield(self):
259+
"""
260+
Return the prime subfield of ``self``.
261+
262+
EXAMPLES::
263+
264+
sage: k = GF(9, 'a') # needs sage.rings.finite_rings
265+
sage: k.prime_subfield() # needs sage.rings.finite_rings
266+
Finite Field of size 3
267+
"""
268+
if self.characteristic() == 0:
269+
import sage.rings.rational_field
270+
return sage.rings.rational_field.RationalField()
271+
272+
from sage.rings.finite_rings.finite_field_constructor import GF
273+
return GF(self.characteristic())
274+
275+
def divides(self, x, y, coerce=True):
276+
"""
277+
Return ``True`` if ``x`` divides ``y`` in this field.
278+
279+
This is usually ``True`` in a field!.
280+
281+
If ``coerce`` is ``True`` (the default), first coerce
282+
``x`` and ``y`` into ``self``.
283+
284+
EXAMPLES::
285+
286+
sage: QQ.divides(2, 3/4)
287+
True
288+
sage: QQ.divides(0, 5)
289+
False
290+
"""
291+
if coerce:
292+
x = self(x)
293+
y = self(y)
294+
if x.is_zero():
295+
return y.is_zero()
296+
return True
297+
243298
def _gcd_univariate_polynomial(self, a, b):
244299
"""
245300
Return the gcd of ``a`` and ``b`` as a monic polynomial.

src/sage/rings/ring.pyx

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -979,40 +979,6 @@ cdef class Field(CommutativeRing):
979979
"""
980980
return self
981981

982-
def divides(self, x, y, coerce=True):
983-
"""
984-
Return ``True`` if ``x`` divides ``y`` in this field (usually ``True``
985-
in a field!). If ``coerce`` is ``True`` (the default), first coerce
986-
``x`` and ``y`` into ``self``.
987-
988-
EXAMPLES::
989-
990-
sage: QQ.divides(2, 3/4)
991-
True
992-
sage: QQ.divides(0, 5)
993-
False
994-
"""
995-
if coerce:
996-
x = self(x)
997-
y = self(y)
998-
if x.is_zero():
999-
return y.is_zero()
1000-
return True
1001-
1002-
def integral_closure(self):
1003-
"""
1004-
Return this field, since fields are integrally closed in their
1005-
fraction field.
1006-
1007-
EXAMPLES::
1008-
1009-
sage: QQ.integral_closure()
1010-
Rational Field
1011-
sage: Frac(ZZ['x,y']).integral_closure()
1012-
Fraction Field of Multivariate Polynomial Ring in x, y over Integer Ring
1013-
"""
1014-
return self
1015-
1016982
def is_field(self, proof=True):
1017983
"""
1018984
Return ``True`` since this is a field.
@@ -1024,23 +990,6 @@ cdef class Field(CommutativeRing):
1024990
"""
1025991
return True
1026992

1027-
def prime_subfield(self):
1028-
"""
1029-
Return the prime subfield of ``self``.
1030-
1031-
EXAMPLES::
1032-
1033-
sage: k = GF(9, 'a') # needs sage.rings.finite_rings
1034-
sage: k.prime_subfield() # needs sage.rings.finite_rings
1035-
Finite Field of size 3
1036-
"""
1037-
if self.characteristic() == 0:
1038-
import sage.rings.rational_field
1039-
return sage.rings.rational_field.RationalField()
1040-
else:
1041-
from sage.rings.finite_rings.finite_field_constructor import GF
1042-
return GF(self.characteristic())
1043-
1044993
def algebraic_closure(self):
1045994
"""
1046995
Return the algebraic closure of ``self``.

0 commit comments

Comments
 (0)