Skip to content

Commit

Permalink
moving "is_prime_field" to the category of rings
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton committed Oct 30, 2024
1 parent 22c6d39 commit 440ffdb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
1 change: 0 additions & 1 deletion src/doc/en/thematic_tutorials/coercion_and_categories.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ This base class provides a lot more methods than a general parent::
'is_commutative',
'is_field',
'is_integrally_closed',
'is_prime_field',
'krull_dimension',
'localization',
'ngens',
Expand Down
24 changes: 24 additions & 0 deletions src/sage/categories/rings.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,30 @@ def is_noetherian(self):
"""
return False

def is_prime_field(self):
r"""
Return ``True`` if this ring is one of the prime fields `\QQ` or
`\GF{p}`.
EXAMPLES::
sage: QQ.is_prime_field()
True
sage: GF(3).is_prime_field()
True
sage: GF(9, 'a').is_prime_field() # needs sage.rings.finite_rings
False
sage: ZZ.is_prime_field()
False
sage: QQ['x'].is_prime_field()
False
sage: Qp(19).is_prime_field() # needs sage.rings.padics
False
"""
# the case of QQ is handled by QQ itself
from sage.categories.finite_fields import FiniteFields
return self in FiniteFields() and self.degree() == 1

def is_zero(self) -> bool:
"""
Return ``True`` if this is the zero ring.
Expand Down
22 changes: 0 additions & 22 deletions src/sage/rings/ring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -652,28 +652,6 @@ cdef class Ring(ParentWithGens):
"""
return True

def is_prime_field(self):
r"""
Return ``True`` if this ring is one of the prime fields `\QQ` or
`\GF{p}`.
EXAMPLES::
sage: QQ.is_prime_field()
True
sage: GF(3).is_prime_field()
True
sage: GF(9, 'a').is_prime_field() # needs sage.rings.finite_rings
False
sage: ZZ.is_prime_field()
False
sage: QQ['x'].is_prime_field()
False
sage: Qp(19).is_prime_field() # needs sage.rings.padics
False
"""
return False

def order(self):
"""
The number of elements of ``self``.
Expand Down

0 comments on commit 440ffdb

Please sign in to comment.