Skip to content

Commit

Permalink
#34537 requires PARI >= 2.15
Browse files Browse the repository at this point in the history
(cherry picked from commit e3af4e3a1e11be18a340946dd97909bd911af1e5)
  • Loading branch information
yyyyx4 committed Feb 8, 2023
1 parent 5dc2c73 commit fc905d5
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions src/sage/rings/number_field/number_field_ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
from sage.structure.proof.proof import get_flag
from sage.structure.richcmp import richcmp

from sage.libs.pari.all import pari_gen, PariError, pari

QQ = rational_field.RationalField()
ZZ = integer_ring.IntegerRing()

Expand Down Expand Up @@ -117,6 +115,7 @@ def __init__(self, field, gens, coerce=True):

if len(gens) == 1 and isinstance(gens[0], (list, tuple)):
gens = gens[0]
from sage.libs.pari.all import pari_gen
if len(gens) == 1 and isinstance(gens[0], pari_gen):
# Init from PARI
gens = gens[0]
Expand Down Expand Up @@ -1017,28 +1016,13 @@ def is_prime(self):
K = self.number_field().pari_nf()
I = self.pari_hnf()

# The function idealismaximal() is broken prior to PARI 2.13.4.
if pari.version() >= (2, 13, 4):
self._pari_prime = K.idealismaximal(I) or None
# PARI uses probabilistic primality testing inside idealismaximal().
if self._pari_prime \
and get_flag(None, 'arithmetic') \
and not self._pari_prime[0].isprime():
self._pari_prime = None
else:
# For other PARI versions, we factor I, but only if the norm is a prime power.
#TODO This can be removed once support for PARI < 2.13.4 has been phased out.
self._pari_prime = K.idealismaximal(I) or None

# PARI uses probabilistic primality testing inside idealismaximal().
if self._pari_prime \
and get_flag(None, 'arithmetic') \
and not self._pari_prime[0].isprime():
self._pari_prime = None
n = self.norm()
try:
n = ZZ(n)
except TypeError:
return False
if not n.is_prime_power():
return False
F = self.factor() # factorization with caching
if len(F) == 1 and F[0][1] == 1:
self._pari_prime = F[0][0]._pari_prime

return self._pari_prime is not None

Expand Down Expand Up @@ -2577,6 +2561,7 @@ def _pari_bid_(self, flag=1):
sage: bid.getattr('clgp')
[2, [2]]
"""
from sage.libs.pari.all import PariError
try:
bid = self._bid
if flag == 2:
Expand Down

0 comments on commit fc905d5

Please sign in to comment.