From 65a729c3ab85f1b2575e07294008a25a7048b9a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Wed, 19 Mar 2025 20:25:34 +0100 Subject: [PATCH 1/3] first adaptations for python3 --- basic_operation.py | 1 + const.py | 1 + diff_operator_pullback_vector_valued.py | 2 +- elements.py | 1 + hecke_module.py | 1 + interpolate.py | 1 + scalar_valued_smfs.py | 1 + tests/test_eigenforms.py | 1 + tests/test_fc_mul_add.py | 1 + tests/test_pullback_se_vector_valued.py | 6 +++--- utils.py | 4 ++-- vector_valued_impl/sym10/tests/test_division.py | 3 +-- vector_valued_impl/sym10/tests/test_ramanujan_conj.py | 2 +- vector_valued_impl/sym10/tests/test_relation.py | 2 +- vector_valued_impl/tests/test_eigenvalue.py | 4 ++-- vector_valued_smfs.py | 2 +- 16 files changed, 20 insertions(+), 13 deletions(-) diff --git a/basic_operation.py b/basic_operation.py index 099c2c0..00f8a71 100644 --- a/basic_operation.py +++ b/basic_operation.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import multiprocessing +from functools import reduce from sage.all import Integer, ZZ, gcd, QQ, mod, floor, sqrt diff --git a/const.py b/const.py index 7e148f4..6475d7c 100644 --- a/const.py +++ b/const.py @@ -5,6 +5,7 @@ from __future__ import print_function +from functools import reduce from abc import ABCMeta, abstractmethod, abstractproperty import os import hashlib diff --git a/diff_operator_pullback_vector_valued.py b/diff_operator_pullback_vector_valued.py index 1e0f223..9bb9a92 100644 --- a/diff_operator_pullback_vector_valued.py +++ b/diff_operator_pullback_vector_valued.py @@ -294,7 +294,7 @@ def fc_of_pullback_of_diff_eisen(l, k, m, A, D, u3, u4, verbose=False): res = res * QQ(mul(k + i for i in range(m))) ** (-1) res = res * _zeta(1 - l) * _zeta(1 - 2 * l + 2) * _zeta(1 - 2 * l + 4) if verbose: - print "Done computation of Fourier coefficient of pullback." + print("Done computation of Fourier coefficient of pullback.") return res diff --git a/elements.py b/elements.py index 6d6e005..1987b5c 100644 --- a/elements.py +++ b/elements.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from abc import ABCMeta, abstractmethod import operator +from functools import reduce from itertools import imap import sage diff --git a/hecke_module.py b/hecke_module.py index 77aa0bd..90f3eb6 100644 --- a/hecke_module.py +++ b/hecke_module.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from functools import reduce from abc import ABCMeta, abstractmethod, abstractproperty import operator diff --git a/interpolate.py b/interpolate.py index 17a3f8c..6ae01cc 100644 --- a/interpolate.py +++ b/interpolate.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import multiprocessing +from functools import reduce from degree2.basic_operation import PrecisionDeg2 from degree2.elements import ModFormQexpLevel1, QexpLevel1 diff --git a/scalar_valued_smfs.py b/scalar_valued_smfs.py index 4db8c04..0cbee60 100644 --- a/scalar_valued_smfs.py +++ b/scalar_valued_smfs.py @@ -2,6 +2,7 @@ import os import operator from abc import ABCMeta, abstractproperty +from functools import reduce import sage from sage.misc.cachefunc import cached_method, cached_function from sage.all import (QQ, save, load, gcd, PolynomialRing, diff --git a/tests/test_eigenforms.py b/tests/test_eigenforms.py index e66d2b0..4cbe7bc 100644 --- a/tests/test_eigenforms.py +++ b/tests/test_eigenforms.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from functools import reduce import unittest import operator diff --git a/tests/test_fc_mul_add.py b/tests/test_fc_mul_add.py index 71c82aa..0e5c9dc 100644 --- a/tests/test_fc_mul_add.py +++ b/tests/test_fc_mul_add.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from functools import reduce from degree2.scalar_valued_smfs import eisenstein_series_degree2, QexpLevel1,\ x10_with_prec, x12_with_prec, x35_with_prec, ModFormQexpLevel1 from degree2.basic_operation import PrecisionDeg2 diff --git a/tests/test_pullback_se_vector_valued.py b/tests/test_pullback_se_vector_valued.py index fdd06e9..ba8aa11 100644 --- a/tests/test_pullback_se_vector_valued.py +++ b/tests/test_pullback_se_vector_valued.py @@ -99,13 +99,13 @@ def assert_pullback_scalar_valued(self, f, t0, ts, l, verbose=False): D = tpl_to_half_int_mat(t0) f = f * f[t0] ** (-1) if verbose: - print "Compute for %s" % (t0,) + print("Compute for %s" % (t0,)) a = fc_of_pullback_of_diff_eisen( l, f.wt, 0, D, D, 1, 1, verbose=verbose) self.assertNotEqual(a, 0) for t in ts: if verbose: - print "Checking for %s" % (t, ) + print("Checking for %s" % (t, )) A = tpl_to_half_int_mat(t) self.assertEqual(fc_of_pullback_of_diff_eisen(l, f.wt, 0, A, D, 1, 1, verbose=verbose), a * f[t]) @@ -189,7 +189,7 @@ def assert_pullback_lin_comb(self, M, f, l, ts, verbose=False): A = tpl_to_half_int_mat(t) fc = fc_of_pullback_of_diff_eisen(l, k, j, A, D, u3_val, u4_val) if verbose: - print "Checking for t = %s" % (t, ) + print("Checking for t = %s" % (t,)) if j > 0: self.assertEqual(fc, f_vec[t]._to_pol()) else: diff --git a/utils.py b/utils.py index 92e63b8..12dc05a 100644 --- a/utils.py +++ b/utils.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import print_function - +from functools import reduce import traceback from multiprocessing import Process, Pipe, cpu_count import operator @@ -236,7 +236,7 @@ def polynomial_func(pl): def is_number(a): - if isinstance(a, (int, float, long, complex, + if isinstance(a, (int, float, complex, sage.rings.all.CommutativeRingElement)): return True elif hasattr(a, 'parent'): diff --git a/vector_valued_impl/sym10/tests/test_division.py b/vector_valued_impl/sym10/tests/test_division.py index a93775e..1521cab 100644 --- a/vector_valued_impl/sym10/tests/test_division.py +++ b/vector_valued_impl/sym10/tests/test_division.py @@ -160,7 +160,6 @@ def _anihilate_pol(k, M): elif k == 13: # Kim-Ramakrishnan-Shahidi lift f = CuspForms(1, 12).basis()[0] - a = f[2] return x - f[2] ** 3 + QQ(2) ** 12 * f[2] else: chrply = M.hecke_charpoly(2) @@ -197,7 +196,7 @@ def test_division_generators(self): gens_dct = calculator.forms_dict(prec) for c in div_consts: k = c.weight() - print "checking when k = %s" % (str(k), ) + print("checking when k = %s" % (str(k),)) if k % 2 == 0: sccst = _find_const_of_e4_e6_of_same_wt(18 - k) M = Sym10EvenDiv(sccst, prec) diff --git a/vector_valued_impl/sym10/tests/test_ramanujan_conj.py b/vector_valued_impl/sym10/tests/test_ramanujan_conj.py index 2a62d9b..2f9c58c 100644 --- a/vector_valued_impl/sym10/tests/test_ramanujan_conj.py +++ b/vector_valued_impl/sym10/tests/test_ramanujan_conj.py @@ -58,7 +58,7 @@ def assert_ramanujan_conj_eigenform(self, f, complex_prec=300): else: embeddings = K.complex_embeddings(prec=complex_prec) if f.phi_operator() == {}: - print "Testing when k = %s" % (f.wt,) + print("Testing when k = %s" % (f.wt,)) for phi in embeddings: pl_cc = pl.map_coefficients(phi) R = PolynomialRing(CC, names=("x",)) diff --git a/vector_valued_impl/sym10/tests/test_relation.py b/vector_valued_impl/sym10/tests/test_relation.py index 681260f..a8bcc14 100644 --- a/vector_valued_impl/sym10/tests/test_relation.py +++ b/vector_valued_impl/sym10/tests/test_relation.py @@ -19,7 +19,7 @@ def test_relation(self): prec = 6 forms_dict = calculator.forms_dict(prec) for wt in [24, 26, 27, 29]: - print "Checking when k = %s" % (wt,) + print("Checking when k = %s" % (wt,)) M = sym10_space(wt, prec, data_directory=data_dir) rel = relation(wt, data_directory=data_dir) self.assertEqual(len(rel), M.dimension() + 1) diff --git a/vector_valued_impl/tests/test_eigenvalue.py b/vector_valued_impl/tests/test_eigenvalue.py index 257d577..f85dcc0 100644 --- a/vector_valued_impl/tests/test_eigenvalue.py +++ b/vector_valued_impl/tests/test_eigenvalue.py @@ -50,7 +50,7 @@ def assert_hecke_eigen_values(self, f, complex_prec=300): else: embeddings = K.complex_embeddings(prec=complex_prec) if f.phi_operator() == {}: - print "Test the Ramanujan conjecture when k = %s, j = %s" % (f.wt, f.sym_wt) + print("Test the Ramanujan conjecture when k = %s, j = %s" % (f.wt, f.sym_wt)) for phi in embeddings: pl_cc = pl.map_coefficients(phi) R = PolynomialRing(CC, names=("x",)) @@ -58,7 +58,7 @@ def assert_hecke_eigen_values(self, f, complex_prec=300): for a, _ in R(pl_cc).roots()) self.assertLess(max_diff, CC(2) ** (-complex_prec + 1)) elif f.base_ring.degree() == 1: - print "Test Kligen Eisenstein series when k = %s, j = %s" % (f.wt, f.sym_wt) + print("Test Kligen Eisenstein series when k = %s, j = %s" % (f.wt, f.sym_wt)) self.assertEqual(f.euler_factor_of_spinor_l(2), _hecke_pol_klingen(f.wt, f.sym_wt)) diff --git a/vector_valued_smfs.py b/vector_valued_smfs.py index 501d57d..736c5e6 100644 --- a/vector_valued_smfs.py +++ b/vector_valued_smfs.py @@ -6,7 +6,7 @@ Ibukiyama, Vector valued Siegel modular forms of symmetric tensor weight of small degrees. ''' - +from functools import reduce import operator from sage.misc.cachefunc import cached_method From f102d751de622a2cb23f6e6a70fc9a6319f4b14a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Wed, 19 Mar 2025 21:25:21 +0100 Subject: [PATCH 2/3] more adaptations to python3 --- const.py | 4 +-- diff_operator_pullback_vector_valued.py | 6 ++-- elements.py | 35 ++++++++++----------- rankin_cohen_diff.py | 4 +-- scalar_valued_smfs.py | 8 ++--- tests/test_eigenforms.py | 4 +-- tests/test_prec_class.py | 2 +- tsushima_dimension_formula.py | 12 ++++--- vector_valued_impl/tests/test_eigenvalue.py | 5 +-- 9 files changed, 41 insertions(+), 39 deletions(-) diff --git a/const.py b/const.py index 6475d7c..6118dfd 100644 --- a/const.py +++ b/const.py @@ -92,7 +92,7 @@ def _frozen_wts(self): if isinstance(self.wts, list): return tuple(self.wts) else: - return frozenset((k, v) for k, v in self.wts.iteritems()) + return frozenset((k, v) for k, v in self.wts.items()) @property def _key(self): @@ -120,7 +120,7 @@ def _calc_from_gens_dict(self, dct): def _monm(ws): return mul(dct[k] for k in ws) - return sum(_monm(k) * v for k, v in coeffs_dct.iteritems()) + return sum(_monm(k) * v for k, v in coeffs_dct.items()) def _polynomial_expr(self): R = PolynomialRing(QQ, diff --git a/diff_operator_pullback_vector_valued.py b/diff_operator_pullback_vector_valued.py index 9bb9a92..528d27f 100644 --- a/diff_operator_pullback_vector_valued.py +++ b/diff_operator_pullback_vector_valued.py @@ -128,7 +128,7 @@ def _z_u_ring_zgens(): def _from_z_dz_ring_to_diff_op(pol): pol = _Z_dZ_ring(pol) - d = {tuple(t): _Z_ring(v) for t, v in pol.dict().iteritems()} + d = {tuple(t): _Z_ring(v) for t, v in pol.dict().items()} return DiffZOperatorElement(d) @@ -285,7 +285,7 @@ def fc_of_pullback_of_diff_eisen(l, k, m, A, D, u3, u4, verbose=False): # L_operator is a differential operator whose order <= m, # we truncate it. pol = _Z_ring( - {t: v for t, v in pol.dict().iteritems() if sum(list(t)) <= m}) + {t: v for t, v in pol.dict().items() if sum(list(t)) <= m}) _l_op_tmp = L_operator(k, m, A, D, r_ls, pol * es.fourier_coefficient(mat), us, d_up_down_mlt) _l_op_tmp = _U_ring({(m - a, a): _l_op_tmp[_u1 ** (m - a) * _u2 ** a] @@ -317,7 +317,7 @@ def _pullback_vector(l, D, u3, u4, space_of_cuspforms, verbose=False): l, k, j, tpl_to_half_int_mat(t), D, u3, u4, verbose=verbose) for t in tpls} pull_back_dct = {k: v.constant_coefficient() - for k, v in pull_back_dct.iteritems()} + for k, v in pull_back_dct.items()} return space_of_cuspforms._to_vector(pull_back_dct) diff --git a/elements.py b/elements.py index 1987b5c..4fc75d8 100644 --- a/elements.py +++ b/elements.py @@ -2,7 +2,6 @@ from abc import ABCMeta, abstractmethod import operator from functools import reduce -from itertools import imap import sage @@ -21,7 +20,7 @@ def to_sorted_fc_list(fc_dct): - dct = {k: v for k, v in fc_dct.iteritems() if v != 0} + dct = {k: v for k, v in fc_dct.items() if v != 0} keys = dct.keys() keys_sorted = sorted(keys, key=lambda x: (max(x[0], x[2]), x[0], x[2], abs(x[1]), x[1])) @@ -62,7 +61,7 @@ def __mul__(self, other): def __eq__(self, other): if other == 0: - return all([x == 0 for x in self.fc_dct.itervalues()]) + return all([x == 0 for x in self.fc_dct.values()]) else: return self - other == 0 @@ -112,7 +111,7 @@ def __getitem__(self, idx): return self.fc_dct[idx] def iteritems(self): - return self.fc_dct.iteritems() + return self.fc_dct.items() def sorted_list(self): return to_sorted_fc_list(self.fc_dct) @@ -161,7 +160,7 @@ def __init__(self, fc_dct, prec, base_ring=QQ, is_cuspidal=False): def __eq__(self, other): if other == 0: - return all([x == 0 for x in self.fc_dct.itervalues()]) + return all([x == 0 for x in self.fc_dct.values()]) else: return self - other == 0 @@ -304,14 +303,14 @@ def __pow__(self, other): def theta_operator4(self): dic = dict() - for k, v in self.fc_dct.iteritems(): + for k, v in self.fc_dct.items(): (n, r, m) = k dic[k] = (4 * n * m - r ** 2) * v return QexpLevel1(dic, self.prec, self.base_ring) def phi_operator(self): d = {n: self[(n, 0, 0)] for n in self.prec._phi_operator_prec()} - return {n: v for n, v in d.iteritems() if v != 0} + return {n: v for n, v in d.items() if v != 0} def gcd_of_coefficients(self): K = self.base_ring @@ -350,7 +349,7 @@ def _differential_operator_monomial(self, a, b, c): del_tau^a del_z^b del_w^c ''' fcmap = {(n, r, m): n ** a * r ** b * m ** c * v for (n, r, m), v - in self.fc_dct.iteritems()} + in self.fc_dct.items()} res = QexpLevel1(fcmap, self.prec, base_ring=self.base_ring, is_cuspidal=self._is_cuspidal) return res @@ -376,11 +375,11 @@ def theta_sym(self, j=2): pl = (r1 * u1 ** 2 + r2 * u1 * u2 + r3 * u2 ** 2) ** (j // 2) pldct = pl.dict() formsdict = {} - for (_, i), ply in pldct.iteritems(): + for (_, i), ply in pldct.items(): formsdict[i] = sum([v * self._differential_operator_monomial(a, b, c) - for (a, b, c), v in ply.dict().iteritems()]) + for (a, b, c), v in ply.dict().items()]) forms = [x for _, x in - sorted([(i, v) for i, v in formsdict.iteritems()], + sorted([(i, v) for i, v in formsdict.items()], key=lambda x: x[0])] return SymWtGenElt(forms, self.prec, self.base_ring) @@ -393,14 +392,14 @@ def change_ring(self, R=None, hom=None): if R is None: R = hom.codomain() fc_map = {} - for k, v in self.fc_dct.iteritems(): + for k, v in self.fc_dct.items(): fc_map[k] = hom(v) return QexpLevel1(fc_map, self.prec, base_ring=R, is_cuspidal=self._is_cuspidal) def mod_p_map(self, p): fcmap = {} - for k, v in self.fc_dct.iteritems(): + for k, v in self.fc_dct.items(): if v != 0: fcmap[k] = modulo(v, p, self.base_ring) return fcmap @@ -544,7 +543,7 @@ def _differential_operator_monomial(self, a, b, c): fcmap = {(n, r, m): ((n - QQ(1) / QQ(2)) ** a * (r + QQ(1) / QQ(2)) ** b * (m - QQ(1) / QQ(2)) ** c * v) - for (n, r, m), v in self.f_part.fc_dct.iteritems()} + for (n, r, m), v in self.f_part.fc_dct.items()} f = QexpLevel1(fcmap, self.prec, base_ring=self.base_ring) return QseriesTimesQminushalf(f) @@ -615,11 +614,11 @@ def __init__(self, wt, fc_dct, prec, base_ring=QQ, if given_reduced_tuples_only: if is_cuspidal or wt % 2 == 1: # level 1 specific. for rdf, col in \ - prec.group_by_reduced_forms_with_sgn().iteritems(): + prec.group_by_reduced_forms_with_sgn().items(): for t, sgn in col: fc_dct[t] = fc_dct[rdf] * sgn ** wt else: - for rdf, col in prec.group_by_reduced_forms().iteritems(): + for rdf, col in prec.group_by_reduced_forms().items(): for t in col: fc_dct[t] = fc_dct[rdf] QexpLevel1.__init__(self, fc_dct, prec, base_ring=base_ring, @@ -631,7 +630,7 @@ def wt(self): def __eq__(self, other): if other == 0: - return all([x == 0 for x in self.fc_dct.itervalues()]) + return all(x == 0 for x in self.fc_dct.values()) else: return self - other == 0 @@ -1165,4 +1164,4 @@ def modulo(x, p, K): a_s = [a ** i for i in range(d)] xl = x.list() xl_p = [mod(b, p).lift() for b in xl] - return sum(list(imap(operator.mul, a_s, xl_p))) + return sum(list(map(operator.mul, a_s, xl_p))) diff --git a/rankin_cohen_diff.py b/rankin_cohen_diff.py index 895e444..7e3edbe 100644 --- a/rankin_cohen_diff.py +++ b/rankin_cohen_diff.py @@ -67,7 +67,7 @@ def _inc_weight(Q): for r11, r12, _ in group(rs, 3): rdct[r11] = 4 * r11 rdct[r12] = 2 * r12 - t = [t for t, v in Q.dict().iteritems() if v != 0][0] + t = [t for t, v in Q.dict().items() if v != 0][0] a = Q.map_coefficients(lambda f: f.subs(rdct))[t] / Q.subs({u1: 2 * u1})[t] return int(log(a) / log(2)) @@ -387,7 +387,7 @@ def _dct(gens, v): dct.update(_dct(gens_z, v3)) return f.subs(dct) - res_dc = {k: pol_to_val(v) for k, v in pol_dc.iteritems()} + res_dc = {k: pol_to_val(v) for k, v in pol_dc.items()} return [res_dc[(j + 2 - i, i)] for i in range(j + 3)] diff --git a/scalar_valued_smfs.py b/scalar_valued_smfs.py index 0cbee60..2412aec 100644 --- a/scalar_valued_smfs.py +++ b/scalar_valued_smfs.py @@ -133,7 +133,7 @@ def load_cached_gens_from_file(prec): prec34_m17_51 = PrecisionDeg2([(34, -17, 51)]) if Deg2global_gens_dict != {}: - a_ky = Deg2global_gens_dict.keys()[0] + a_ky = next(iter(Deg2global_gens_dict.keys())) if Deg2global_gens_dict[a_ky].prec >= prec: return None @@ -148,7 +148,7 @@ def load_cached_gens_from_file(prec): gens_dct1 = load(os.path.join(cached_dir, '_fc_dict39.sobj')) gens_dct2 = load(os.path.join(cached_dir, '_fc_dict_tuples_34_-17_51.sobj')) - for k in gens_dct1.keys(): + for k in gens_dct1: gens_dct1[k].update(gens_dct2[k]) gens_dct = {k: {t: gens_dct1[k][t] for t in prec} for k in gens_dct1.keys()} @@ -297,7 +297,7 @@ def x5_jacobi_g(n, r, prec=40): psr = x5_jacobi_pwsr((prec - 1) // 2) l_pol = psr[(n - 1) // 2] d = {} - a_key = l_pol.dict().keys()[0] + a_key = next(iter(l_pol.dict())) is_int_key = isinstance(a_key, int) is_etuple = isinstance(a_key, sage.rings.polynomial.polydict.ETuple) for k, v in l_pol.dict().items(): @@ -694,7 +694,7 @@ def _hecke_tp2_charpoly(self, p, var='x', algorithm='linbox'): def morph(a, b, f, m): G = (-1) ** m * f.subs({x: -x}) * f - alst = [[k // 2, v] for k, v in G.dict().iteritems()] + alst = [[k // 2, v] for k, v in G.dict().items()] F = sum([v * x ** k for k, v in alst]) return a ** m * F.subs({x: (x - b) / a}) f1 = morph(u ** 2 + u + 1, -p * u ** 3 - u ** 2 - p * u, f, m) diff --git a/tests/test_eigenforms.py b/tests/test_eigenforms.py index 4cbe7bc..3af8e91 100644 --- a/tests/test_eigenforms.py +++ b/tests/test_eigenforms.py @@ -51,7 +51,7 @@ def polynomial_to_form(f, prec): def monom(t): return reduce(operator.mul, [f ** a for f, a in zip(gens, t)]) - return sum([a * monom(t) for t, a in f.dict().iteritems()]) + return sum([a * monom(t) for t, a in f.dict().items()]) x47_fc_dct = load_cache("x47_fc_dct.sobj") @@ -163,7 +163,7 @@ def test_wt_35_eigenvalues(self): def test_es4_eigenvalues(self): es4 = eisenstein_series_degree2(4, 25) d = {2: 45, 3: 280, 4: 1549, 5: 3276, 9: 69049, 25: 10256401} - for k, v in d.iteritems(): + for k, v in d.items(): self.assertTrue(es4.hecke_eigenvalue(k) == v) def test_cusp_sp_wt28_hecke_charpoly(self): diff --git a/tests/test_prec_class.py b/tests/test_prec_class.py index 9776d63..18900ff 100644 --- a/tests/test_prec_class.py +++ b/tests/test_prec_class.py @@ -27,7 +27,7 @@ def test_le(self): def test_group_by_reduced_forms_with_sgn(self): prec = 8 bls = [] - for t, ls in PrecisionDeg2(prec).group_by_reduced_forms_with_sgn().iteritems(): + for t, ls in PrecisionDeg2(prec).group_by_reduced_forms_with_sgn().items(): rdf_t, sgn_t = reduced_form_with_sign(t) for t1, sgn in ls: _, sgn_t1 = reduced_form_with_sign(t1) diff --git a/tsushima_dimension_formula.py b/tsushima_dimension_formula.py index ae610d0..c7358c0 100644 --- a/tsushima_dimension_formula.py +++ b/tsushima_dimension_formula.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- from sage.all import (NumberField, var, QQ, PolynomialRing, cached_function, - dimension_cusp_forms, O, PowerSeriesRing) + O, PowerSeriesRing) +from sage.modular.dims import dimension_cusp_forms + global_ring = PolynomialRing(QQ, names="t,s") @@ -22,7 +24,7 @@ def mul(a, g): return a * nm / dm return sum([mul(v, derivative_exp(derivative_exp(f, a, t), b, s)) - for (a, b), v in pl.dict().iteritems()]) + for (a, b), v in pl.dict().items()]) def trace(f, key): @@ -44,8 +46,8 @@ def root_of_unities(): "rho": x ** 2 + x + 1, "omega": x ** 4 + x ** 3 + x ** 2 + x + 1, "sigma": x ** 4 - x ** 2 + 1} - dctnm = {k: NumberField(v, names=k) for k, v in dct.iteritems()} - return {k: v.gens()[0] for k, v in dctnm.iteritems()} + dctnm = {k: NumberField(v, names=k) for k, v in dct.items()} + return {k: v.gens()[0] for k, v in dctnm.items()} two = QQ(2) @@ -169,7 +171,7 @@ def gen_func_maybe_cusp_num_t(parity=None): else: e = parity % 2 nm = sum([t ** a * s ** b * v for (a, b), v in - nm.dict().iteritems() if a % 2 == e]) + nm.dict().items() if a % 2 == e]) return nm / dnm2 diff --git a/vector_valued_impl/tests/test_eigenvalue.py b/vector_valued_impl/tests/test_eigenvalue.py index f85dcc0..46ce1af 100644 --- a/vector_valued_impl/tests/test_eigenvalue.py +++ b/vector_valued_impl/tests/test_eigenvalue.py @@ -1,6 +1,7 @@ from sage.all import (ComplexField, NumberField, PolynomialRing, CuspForms, QQ, - CartesianProduct, fork) + fork) import unittest +from itertools import product from degree2.vector_valued_smfs import vector_valued_siegel_modular_forms as vvsmf from degree2.basic_operation import number_of_procs @@ -82,7 +83,7 @@ def _check(k, j): self.assert_hecke_eigen_values(f) with number_of_procs(1): - for k, j in CartesianProduct(range(4, 30), [2, 4, 10]): + for k, j in product(range(4, 30), [2, 4, 10]): _check(k, j) suite = unittest.TestLoader().loadTestsFromTestCase(RamanujanConjandKlingen) From 5a288b48df7dc706e30e14c3006039fe3e5c80f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Wed, 19 Mar 2025 21:37:04 +0100 Subject: [PATCH 3/3] one more fix for py3 --- basic_operation.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/basic_operation.py b/basic_operation.py index 00f8a71..200193d 100644 --- a/basic_operation.py +++ b/basic_operation.py @@ -337,12 +337,11 @@ def _spos_def_mats_lt(tpl): def _key_of_tuples(prec, cuspidal=False, hol=False): if cuspidal and not hol: return list(PrecisionDeg2(prec).pos_defs()) - elif hol and cuspidal: - return prec.group_by_reduced_forms_with_sgn().keys() - elif hol and not cuspidal: - return prec.group_by_reduced_forms().keys() - else: - return list(PrecisionDeg2(prec)) + if hol and cuspidal: + return list(prec.group_by_reduced_forms_with_sgn()) + if hol and not cuspidal: + return list(prec.group_by_reduced_forms()) + return list(PrecisionDeg2(prec)) @cached_function