Skip to content

Commit a010b5d

Browse files
committed
remove deprecated method in quaternion algebra
1 parent 665a3fa commit a010b5d

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
@@ -1015,7 +1014,7 @@ def maximal_order(self, take_shortcuts=True, order_basis=None):
10151014
# of such a form though)
10161015
a, b = self.invariants()
10171016
if (not order_basis and take_shortcuts and d_A.is_prime()
1018-
and a in ZZ and b in ZZ):
1017+
and a in ZZ and b in ZZ):
10191018
a = ZZ(a)
10201019
b = ZZ(b)
10211020
i, j, k = self.gens()
@@ -1057,7 +1056,7 @@ def maximal_order(self, take_shortcuts=True, order_basis=None):
10571056
d_R = R.discriminant()
10581057
except (TypeError, ValueError):
10591058
raise ValueError('order_basis is not a basis of an order of the'
1060-
' given quaternion algebra')
1059+
' given quaternion algebra')
10611060

10621061
# Since Voight's algorithm only works for a starting basis having 1 as
10631062
# its first vector, we derive such a basis from the given order basis
@@ -1134,7 +1133,7 @@ def maximal_order(self, take_shortcuts=True, order_basis=None):
11341133
e_n[3] = e_n[1]*g
11351134

11361135
else: # t.valuation(p) > 0
1137-
(y, z, w) = maxord_solve_aux_eq(a, b, p)
1136+
y, z, w = maxord_solve_aux_eq(a, b, p)
11381137
g = 1/p*(1 + y*e_n[1] + z*e_n[2] + w*e_n[1]*e_n[2])
11391138
h = (z*b)*e_n[1] - (y*a)*e_n[2]
11401139
e_n[1:4] = [g, h, g * h]
@@ -1571,7 +1570,8 @@ def ramified_places(self, inf=True):
15711570

15721571
# Over the number field F, first compute the finite ramified places
15731572
ram_fin = [p for p in set(F.primes_above(2)).union(F.primes_above(a),
1574-
F.primes_above(b)) if F.hilbert_symbol(a, b, p) == -1]
1573+
F.primes_above(b))
1574+
if F.hilbert_symbol(a, b, p) == -1]
15751575

15761576
if not inf:
15771577
return ram_fin
@@ -2757,7 +2757,7 @@ def ternary_quadratic_form(self, include_basis=False):
27572757
Q = self.quaternion_algebra()
27582758
# 2*R + ZZ
27592759
twoR = self.free_module().scale(2)
2760-
Z = twoR.span([Q(1).coefficient_tuple()], ZZ)
2760+
Z = twoR.span([Q.one().coefficient_tuple()], ZZ)
27612761
S = twoR + Z
27622762
# Now we intersect with the trace 0 submodule
27632763
v = [b.reduced_trace() for b in Q.basis()]
@@ -3621,7 +3621,7 @@ def norm(self):
36213621
[16, 32, 32]
36223622
36233623
sage: # optional - magma
3624-
sage: (a,b) = M.quaternion_algebra().invariants()
3624+
sage: a, b = M.quaternion_algebra().invariants()
36253625
sage: magma.eval('A<i,j,k> := QuaternionAlgebra<Rationals() | %s, %s>' % (a,b))
36263626
''
36273627
sage: magma.eval('O := QuaternionOrder(%s)' % str(list(C[0].right_order().basis())))
@@ -4023,24 +4023,21 @@ def pullback(self, J, side=None):
40234023

40244024
raise ValueError('side must be "left", "right" or None')
40254025

4026-
def is_equivalent(self, J, B=10, certificate=False, side=None):
4026+
def is_left_equivalent(self, J, B=10, certificate=False) -> bool | tuple:
40274027
r"""
4028-
Check whether ``self`` and ``J`` are equivalent as ideals.
4029-
Tests equivalence as right ideals by default. Requires the underlying
4030-
rational quaternion algebra to be definite.
4028+
Check whether ``self`` and ``J`` are equivalent as left ideals.
4029+
4030+
This requires the underlying rational quaternion algebra
4031+
to be definite.
40314032
40324033
INPUT:
40334034
4034-
- ``J`` -- a fractional quaternion ideal with same order as ``self``
4035+
- ``J`` -- a fractional quaternion left ideal with same order as ``self``
40354036
40364037
- ``B`` -- a bound to compute and compare theta series before
40374038
doing the full equivalence test
40384039
4039-
- ``certificate`` -- if ``True`` returns an element alpha such that
4040-
alpha*J = I or J*alpha = I for right and left ideals respectively
4041-
4042-
- ``side`` -- if ``'left'`` performs left equivalence test. If ``'right'
4043-
``or ``None`` performs right ideal equivalence test
4040+
- ``certificate`` -- if ``True`` returns an element alpha such that J*alpha=I
40444041
40454042
OUTPUT: boolean, or (boolean, alpha) if ``certificate`` is ``True``
40464043
@@ -4050,48 +4047,22 @@ def is_equivalent(self, J, B=10, certificate=False, side=None):
40504047
2
40514048
sage: OO = R[0].left_order()
40524049
sage: S = OO.right_ideal([3*a for a in R[0].basis()])
4053-
sage: R[0].is_equivalent(S)
4054-
doctest:...: DeprecationWarning: is_equivalent is deprecated,
4055-
please use is_left_equivalent or is_right_equivalent
4056-
accordingly instead
4057-
See https://github.com/sagemath/sage/issues/37100 for details.
4050+
sage: R[0].is_left_equivalent(S)
40584051
True
40594052
"""
4060-
from sage.misc.superseded import deprecation
4061-
deprecation(37100, 'is_equivalent is deprecated, please use is_left_equivalent'
4062-
' or is_right_equivalent accordingly instead')
4063-
if side == 'left':
4064-
return self.is_left_equivalent(J, B, certificate)
4065-
# If None, assume right ideals, for backwards compatibility
4066-
return self.is_right_equivalent(J, B, certificate)
4067-
4068-
def is_left_equivalent(self, J, B=10, certificate=False):
4069-
r"""
4070-
Check whether ``self`` and ``J`` are equivalent as left ideals.
4071-
Requires the underlying rational quaternion algebra to be definite.
4072-
4073-
INPUT:
4074-
4075-
- ``J`` -- a fractional quaternion left ideal with same order as ``self``
4076-
4077-
- ``B`` -- a bound to compute and compare theta series before
4078-
doing the full equivalence test
4079-
4080-
- ``certificate`` -- if ``True`` returns an element alpha such that J*alpha=I
4081-
4082-
OUTPUT: boolean, or (boolean, alpha) if ``certificate`` is ``True``
4083-
"""
40844053
if certificate:
40854054
is_equiv, cert = self.conjugate().is_right_equivalent(J.conjugate(), B, True)
40864055
if is_equiv:
40874056
return True, cert.conjugate()
40884057
return False, None
40894058
return self.conjugate().is_right_equivalent(J.conjugate(), B, False)
40904059

4091-
def is_right_equivalent(self, J, B=10, certificate=False):
4060+
def is_right_equivalent(self, J, B=10, certificate=False) -> bool | tuple:
40924061
r"""
40934062
Check whether ``self`` and ``J`` are equivalent as right ideals.
4094-
Requires the underlying rational quaternion algebra to be definite.
4063+
4064+
This requires the underlying rational quaternion algebra
4065+
to be definite.
40954066
40964067
INPUT:
40974068
@@ -4135,14 +4106,14 @@ def is_right_equivalent(self, J, B=10, certificate=False):
41354106
"""
41364107
if not isinstance(J, QuaternionFractionalIdeal_rational):
41374108
raise TypeError('J must be a fractional ideal'
4138-
' in a rational quaternion algebra')
4109+
' in a rational quaternion algebra')
41394110

41404111
if self.right_order() != J.right_order():
41414112
raise ValueError('self and J must be right ideals over the same order')
41424113

41434114
if not self.quaternion_algebra().is_definite():
41444115
raise NotImplementedError('equivalence test of ideals not implemented'
4145-
' for indefinite quaternion algebras')
4116+
' for indefinite quaternion algebras')
41464117

41474118
# Just test theta series first; if the theta series are
41484119
# different, the ideals are definitely not equivalent
@@ -4191,7 +4162,7 @@ def is_principal(self, certificate=False):
41914162
"""
41924163
if not self.quaternion_algebra().is_definite():
41934164
raise NotImplementedError('principality test not implemented in'
4194-
' indefinite quaternion algebras')
4165+
' indefinite quaternion algebras')
41954166

41964167
c = self.theta_series_vector(2)[1]
41974168
if not certificate:
@@ -4421,10 +4392,12 @@ def primitive_decomposition(self):
44214392
44224393
Check that randomly generated ideals decompose as expected::
44234394
4424-
sage: for d in ( m for m in range(400, 750) if is_squarefree(m) ): # long time (7s)
4395+
sage: for d in range(400, 650): # long time (7s)
4396+
....: if not is_squarefree(d):
4397+
....: continue
44254398
....: A = QuaternionAlgebra(d)
44264399
....: O = A.maximal_order()
4427-
....: for _ in range(10):
4400+
....: for _ in range(8):
44284401
....: a = O.random_element()
44294402
....: if not a.is_constant(): # avoids a = 0
44304403
....: I = a*O + a.reduced_norm()*O
@@ -4719,7 +4692,7 @@ def maxord_solve_aux_eq(a, b, p):
47194692
sage: from sage.algebras.quatalg.quaternion_algebra import maxord_solve_aux_eq
47204693
sage: for a in [1,3]:
47214694
....: for b in [1,2,3]:
4722-
....: (y,z,w) = maxord_solve_aux_eq(a, b, 2)
4695+
....: y, z, w = maxord_solve_aux_eq(a, b, 2)
47234696
....: assert mod(y, 4) == 1 or mod(y, 4) == 3
47244697
....: assert mod(1 - a*y^2 - b*z^2 + a*b*w^2, 4) == 0
47254698
"""

0 commit comments

Comments
 (0)