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

Commit

Permalink
add deprecation warning for #34806
Browse files Browse the repository at this point in the history
  • Loading branch information
yyyyx4 committed Nov 29, 2022
1 parent 84f02af commit 40363f1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/sage/rings/number_field/number_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -12522,7 +12522,7 @@ def map_Zmstar_to_Zm(h):
p = u.lift()
while not p.is_prime():
p += m
f = R.ideal(p).prime_factors()[0].residue_class_degree()
f = K.fractional_ideal(p).prime_factors()[0].residue_class_degree()
h = g**f
if h not in H:
Hgens += [h]
Expand Down
11 changes: 7 additions & 4 deletions src/sage/rings/number_field/number_field_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,8 @@ def _inverse_mod_generic(elt, I):
"""
from sage.matrix.constructor import matrix
R = elt.parent()
try:
I = R.ideal(I)
except ValueError:
I = R.number_field().fractional_ideal(I)
if not I.is_integral():
raise ValueError("inverse is only defined modulo integral ideals")
if I == 0:
raise ValueError("inverse is not defined modulo the zero ideal")
Expand Down Expand Up @@ -1984,6 +1983,9 @@ cdef class NumberFieldElement(FieldElement):
raise ArithmeticError("factorization of 0 is not defined")

K = self.parent()
from .order import is_NumberFieldOrder
if is_NumberFieldOrder(K):
K = K.number_field()
fac = K.ideal(self).factor()
# Check whether all prime ideals in `fac` are principal
for P,e in fac:
Expand Down Expand Up @@ -2065,7 +2067,8 @@ cdef class NumberFieldElement(FieldElement):
if not is_NumberFieldOrder(R) or not R.is_maximal():
raise NotImplementedError("gcd() for %r is not implemented" % R)

g = R.ideal(self, other).gens_reduced()
K = R.number_field()
g = K.fractional_ideal(self, other).gens_reduced()
if len(g) > 1:
raise ArithmeticError("ideal (%r, %r) is not principal, gcd is not defined" % (self, other) )

Expand Down
8 changes: 8 additions & 0 deletions src/sage/rings/number_field/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,14 @@ def ideal(self, *args, **kwds):
"""
if not self.is_maximal():
raise NotImplementedError("ideals of non-maximal orders not yet supported.")
from sage.misc.superseded import deprecation
deprecation(34806, 'In the future, constructing an ideal of the ring of '
'integers of a number field will use an implementation '
'compatible with ideals of other (non-maximal) orders, '
'rather than returning an integral fractional ideal of '
'its containing number field. Use .fractional_ideal(), '
'together with an .is_integral() check if desired, to '
'avoid your code breaking with future changes to Sage.')
I = self.number_field().ideal(*args, **kwds)
if not I.is_integral():
raise ValueError("ideal must be integral; use fractional_ideal to create a non-integral ideal.")
Expand Down

0 comments on commit 40363f1

Please sign in to comment.