b34d0bbd28
Also fix doctests for pkg updates: - matplotlib 3.7 - ipython 8.12 - nauty 2.8.6 - pythran 0.12.1 And add support for: - networkx 3.1 We use patches from upstream sagemath to fix all of these. We also add pythran and sphinx to checkdepends to make sure doctests pass when they are installed.
49 lines
1.7 KiB
Diff
49 lines
1.7 KiB
Diff
diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
|
|
index d5f7157217f..8ca1f958039 100644
|
|
--- a/src/sage/rings/number_field/number_field_ideal.py
|
|
+++ b/src/sage/rings/number_field/number_field_ideal.py
|
|
@@ -996,16 +996,38 @@ def is_prime(self):
|
|
False
|
|
sage: K.ideal(17).is_prime() # ramified
|
|
False
|
|
+
|
|
+ TESTS:
|
|
+
|
|
+ Check that we do not factor the norm of the ideal, this used
|
|
+ to take half an hour, see :trac:`33360`::
|
|
+
|
|
+ sage: K.<a,b,c> = NumberField([x^2-2,x^2-3,x^2-5])
|
|
+ sage: t = (((-2611940*c + 1925290/7653)*b - 1537130/7653*c
|
|
+ ....: + 10130950)*a + (1343014/7653*c - 8349770)*b
|
|
+ ....: + 6477058*c - 2801449990/4002519)
|
|
+ sage: t.is_prime()
|
|
+ False
|
|
"""
|
|
try:
|
|
return self._pari_prime is not None
|
|
except AttributeError:
|
|
- F = self.factor() # factorization with caching
|
|
- if len(F) != 1 or F[0][1] != 1:
|
|
- self._pari_prime = None
|
|
- else:
|
|
- self._pari_prime = F[0][0]._pari_prime
|
|
- return self._pari_prime is not None
|
|
+ pass
|
|
+
|
|
+ K = self.number_field().pari_nf()
|
|
+ I = self.pari_hnf()
|
|
+
|
|
+ candidate = K.idealismaximal(I) or None
|
|
+
|
|
+ # PARI uses probabilistic primality testing inside idealismaximal().
|
|
+ if get_flag(None, 'arithmetic'):
|
|
+ # proof required, check using isprime()
|
|
+ if candidate and not candidate[0].isprime():
|
|
+ candidate = None
|
|
+
|
|
+ self._pari_prime = candidate
|
|
+
|
|
+ return self._pari_prime is not None
|
|
|
|
def pari_prime(self):
|
|
r"""
|