Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Raise an error in FieldElement.is_prime()
Browse files Browse the repository at this point in the history
  • Loading branch information
jdemeyer committed Mar 9, 2015
1 parent 319abe2 commit f0e8c96
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/sage/structure/element.pyx
Expand Up @@ -2089,13 +2089,6 @@ cdef class RingElement(ModuleElement):
sage: ZI(1).is_prime()
False
In fields, an element is never prime::
sage: RR(0).is_prime()
False
sage: RR(2).is_prime()
False
For integers, prime numbers are redefined to be positive::
sage: RingElement.is_prime(-2)
Expand Down Expand Up @@ -3142,6 +3135,22 @@ cdef class FieldElement(CommutativeRingElement):
"""
return not not self

def is_prime(self):
"""
Is ``self`` a prime element?
Since this question is meaningless for a field (applying the
definition, the answer is always ``False``), we raise an error.
EXAMPLES::
sage: QQ(2).is_prime()
Traceback (most recent call last):
...
ArithmeticError: is_prime() is meaningless for elements of the field 'Rational Field'
"""
raise ArithmeticError("is_prime() is meaningless for elements of the field '%s'" % self._parent)

def _lcm(self, FieldElement other):
"""
Return the least common multiple of ``self`` and other.
Expand Down

0 comments on commit f0e8c96

Please sign in to comment.