Skip to content

Commit 456cfc9

Browse files
author
Release Manager
committed
gh-40345: remove deprecated method in quaternion algebra remove deprecation from #37100 also clean the modified file a little bit ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. URL: #40345 Reported by: Frédéric Chapoton Reviewer(s):
2 parents 4512db8 + a010b5d commit 456cfc9

File tree

1 file changed

+29
-56
lines changed

1 file changed

+29
-56
lines changed

src/sage/algebras/quatalg/quaternion_algebra.py

Lines changed: 29 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
from sage.categories.number_fields import NumberFields
9191

9292
from sage.structure.richcmp import richcmp_method
93-
from sage.libs.pari.all import pari
9493
from sage.combinat.words.word import Word
9594

9695
########################################################
@@ -366,7 +365,7 @@ def create_key(self, arg0, arg1=None, arg2=None, names='i,j,k'):
366365
K = arg0
367366
if K not in NumberFields():
368367
raise ValueError("quaternion algebra construction via ramification only works over a number field")
369-
if not set(arg2).issubset(set([0, QQ((1,2))])):
368+
if not set(arg2).issubset(set([0, QQ((1, 2))])):
370369
raise ValueError("list of local invariants specifying ramification should contain only 0 and 1/2")
371370

372371
# Check that the finite ramification is given by prime ideals
@@ -417,7 +416,7 @@ def create_key(self, arg0, arg1=None, arg2=None, names='i,j,k'):
417416
inv_arch_pari = [arg2[i-1] for i in perm]
418417

419418
# Compute the correct quaternion algebra over L in PARI
420-
A = L.__pari__().alginit([2, [fin_places_pari, [QQ((1,2))] * len(fin_places_pari)],
419+
A = L.__pari__().alginit([2, [fin_places_pari, [QQ((1, 2))] * len(fin_places_pari)],
421420
inv_arch_pari], flag=0)
422421

423422
# Obtain representation of A in terms of invariants in L
@@ -1008,7 +1007,7 @@ def maximal_order(self, take_shortcuts=True, order_basis=None):
10081007
# of such a form though)
10091008
a, b = self.invariants()
10101009
if (not order_basis and take_shortcuts and d_A.is_prime()
1011-
and a in ZZ and b in ZZ):
1010+
and a in ZZ and b in ZZ):
10121011
a = ZZ(a)
10131012
b = ZZ(b)
10141013
i, j, k = self.gens()
@@ -1050,7 +1049,7 @@ def maximal_order(self, take_shortcuts=True, order_basis=None):
10501049
d_R = R.discriminant()
10511050
except (TypeError, ValueError):
10521051
raise ValueError('order_basis is not a basis of an order of the'
1053-
' given quaternion algebra')
1052+
' given quaternion algebra')
10541053

10551054
# Since Voight's algorithm only works for a starting basis having 1 as
10561055
# its first vector, we derive such a basis from the given order basis
@@ -1127,7 +1126,7 @@ def maximal_order(self, take_shortcuts=True, order_basis=None):
11271126
e_n[3] = e_n[1]*g
11281127

11291128
else: # t.valuation(p) > 0
1130-
(y, z, w) = maxord_solve_aux_eq(a, b, p)
1129+
y, z, w = maxord_solve_aux_eq(a, b, p)
11311130
g = 1/p*(1 + y*e_n[1] + z*e_n[2] + w*e_n[1]*e_n[2])
11321131
h = (z*b)*e_n[1] - (y*a)*e_n[2]
11331132
e_n[1:4] = [g, h, g * h]
@@ -1564,7 +1563,8 @@ def ramified_places(self, inf=True):
15641563

15651564
# Over the number field F, first compute the finite ramified places
15661565
ram_fin = [p for p in set(F.primes_above(2)).union(F.primes_above(a),
1567-
F.primes_above(b)) if F.hilbert_symbol(a, b, p) == -1]
1566+
F.primes_above(b))
1567+
if F.hilbert_symbol(a, b, p) == -1]
15681568

15691569
if not inf:
15701570
return ram_fin
@@ -2750,7 +2750,7 @@ def ternary_quadratic_form(self, include_basis=False):
27502750
Q = self.quaternion_algebra()
27512751
# 2*R + ZZ
27522752
twoR = self.free_module().scale(2)
2753-
Z = twoR.span([Q(1).coefficient_tuple()], ZZ)
2753+
Z = twoR.span([Q.one().coefficient_tuple()], ZZ)
27542754
S = twoR + Z
27552755
# Now we intersect with the trace 0 submodule
27562756
v = [b.reduced_trace() for b in Q.basis()]
@@ -3614,7 +3614,7 @@ def norm(self):
36143614
[16, 32, 32]
36153615
36163616
sage: # optional - magma
3617-
sage: (a,b) = M.quaternion_algebra().invariants()
3617+
sage: a, b = M.quaternion_algebra().invariants()
36183618
sage: magma.eval('A<i,j,k> := QuaternionAlgebra<Rationals() | %s, %s>' % (a,b))
36193619
''
36203620
sage: magma.eval('O := QuaternionOrder(%s)' % str(list(C[0].right_order().basis())))
@@ -4016,24 +4016,21 @@ def pullback(self, J, side=None):
40164016

40174017
raise ValueError('side must be "left", "right" or None')
40184018

4019-
def is_equivalent(self, J, B=10, certificate=False, side=None):
4019+
def is_left_equivalent(self, J, B=10, certificate=False) -> bool | tuple:
40204020
r"""
4021-
Check whether ``self`` and ``J`` are equivalent as ideals.
4022-
Tests equivalence as right ideals by default. Requires the underlying
4023-
rational quaternion algebra to be definite.
4021+
Check whether ``self`` and ``J`` are equivalent as left ideals.
4022+
4023+
This requires the underlying rational quaternion algebra
4024+
to be definite.
40244025
40254026
INPUT:
40264027
4027-
- ``J`` -- a fractional quaternion ideal with same order as ``self``
4028+
- ``J`` -- a fractional quaternion left ideal with same order as ``self``
40284029
40294030
- ``B`` -- a bound to compute and compare theta series before
40304031
doing the full equivalence test
40314032
4032-
- ``certificate`` -- if ``True`` returns an element alpha such that
4033-
alpha*J = I or J*alpha = I for right and left ideals respectively
4034-
4035-
- ``side`` -- if ``'left'`` performs left equivalence test. If ``'right'
4036-
``or ``None`` performs right ideal equivalence test
4033+
- ``certificate`` -- if ``True`` returns an element alpha such that J*alpha=I
40374034
40384035
OUTPUT: boolean, or (boolean, alpha) if ``certificate`` is ``True``
40394036
@@ -4043,48 +4040,22 @@ def is_equivalent(self, J, B=10, certificate=False, side=None):
40434040
2
40444041
sage: OO = R[0].left_order()
40454042
sage: S = OO.right_ideal([3*a for a in R[0].basis()])
4046-
sage: R[0].is_equivalent(S)
4047-
doctest:...: DeprecationWarning: is_equivalent is deprecated,
4048-
please use is_left_equivalent or is_right_equivalent
4049-
accordingly instead
4050-
See https://github.com/sagemath/sage/issues/37100 for details.
4043+
sage: R[0].is_left_equivalent(S)
40514044
True
40524045
"""
4053-
from sage.misc.superseded import deprecation
4054-
deprecation(37100, 'is_equivalent is deprecated, please use is_left_equivalent'
4055-
' or is_right_equivalent accordingly instead')
4056-
if side == 'left':
4057-
return self.is_left_equivalent(J, B, certificate)
4058-
# If None, assume right ideals, for backwards compatibility
4059-
return self.is_right_equivalent(J, B, certificate)
4060-
4061-
def is_left_equivalent(self, J, B=10, certificate=False):
4062-
r"""
4063-
Check whether ``self`` and ``J`` are equivalent as left ideals.
4064-
Requires the underlying rational quaternion algebra to be definite.
4065-
4066-
INPUT:
4067-
4068-
- ``J`` -- a fractional quaternion left ideal with same order as ``self``
4069-
4070-
- ``B`` -- a bound to compute and compare theta series before
4071-
doing the full equivalence test
4072-
4073-
- ``certificate`` -- if ``True`` returns an element alpha such that J*alpha=I
4074-
4075-
OUTPUT: boolean, or (boolean, alpha) if ``certificate`` is ``True``
4076-
"""
40774046
if certificate:
40784047
is_equiv, cert = self.conjugate().is_right_equivalent(J.conjugate(), B, True)
40794048
if is_equiv:
40804049
return True, cert.conjugate()
40814050
return False, None
40824051
return self.conjugate().is_right_equivalent(J.conjugate(), B, False)
40834052

4084-
def is_right_equivalent(self, J, B=10, certificate=False):
4053+
def is_right_equivalent(self, J, B=10, certificate=False) -> bool | tuple:
40854054
r"""
40864055
Check whether ``self`` and ``J`` are equivalent as right ideals.
4087-
Requires the underlying rational quaternion algebra to be definite.
4056+
4057+
This requires the underlying rational quaternion algebra
4058+
to be definite.
40884059
40894060
INPUT:
40904061
@@ -4128,14 +4099,14 @@ def is_right_equivalent(self, J, B=10, certificate=False):
41284099
"""
41294100
if not isinstance(J, QuaternionFractionalIdeal_rational):
41304101
raise TypeError('J must be a fractional ideal'
4131-
' in a rational quaternion algebra')
4102+
' in a rational quaternion algebra')
41324103

41334104
if self.right_order() != J.right_order():
41344105
raise ValueError('self and J must be right ideals over the same order')
41354106

41364107
if not self.quaternion_algebra().is_definite():
41374108
raise NotImplementedError('equivalence test of ideals not implemented'
4138-
' for indefinite quaternion algebras')
4109+
' for indefinite quaternion algebras')
41394110

41404111
# Just test theta series first; if the theta series are
41414112
# different, the ideals are definitely not equivalent
@@ -4184,7 +4155,7 @@ def is_principal(self, certificate=False):
41844155
"""
41854156
if not self.quaternion_algebra().is_definite():
41864157
raise NotImplementedError('principality test not implemented in'
4187-
' indefinite quaternion algebras')
4158+
' indefinite quaternion algebras')
41884159

41894160
c = self.theta_series_vector(2)[1]
41904161
if not certificate:
@@ -4414,10 +4385,12 @@ def primitive_decomposition(self):
44144385
44154386
Check that randomly generated ideals decompose as expected::
44164387
4417-
sage: for d in ( m for m in range(400, 750) if is_squarefree(m) ): # long time (7s)
4388+
sage: for d in range(400, 650): # long time (7s)
4389+
....: if not is_squarefree(d):
4390+
....: continue
44184391
....: A = QuaternionAlgebra(d)
44194392
....: O = A.maximal_order()
4420-
....: for _ in range(10):
4393+
....: for _ in range(8):
44214394
....: a = O.random_element()
44224395
....: if not a.is_constant(): # avoids a = 0
44234396
....: I = a*O + a.reduced_norm()*O
@@ -4712,7 +4685,7 @@ def maxord_solve_aux_eq(a, b, p):
47124685
sage: from sage.algebras.quatalg.quaternion_algebra import maxord_solve_aux_eq
47134686
sage: for a in [1,3]:
47144687
....: for b in [1,2,3]:
4715-
....: (y,z,w) = maxord_solve_aux_eq(a, b, 2)
4688+
....: y, z, w = maxord_solve_aux_eq(a, b, 2)
47164689
....: assert mod(y, 4) == 1 or mod(y, 4) == 3
47174690
....: assert mod(1 - a*y^2 - b*z^2 + a*b*w^2, 4) == 0
47184691
"""

0 commit comments

Comments
 (0)