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

Commit

Permalink
more print converted to python3 in py files
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric Chapoton committed Jun 12, 2016
1 parent 715566f commit 5ef5316
Show file tree
Hide file tree
Showing 19 changed files with 198 additions and 183 deletions.
24 changes: 12 additions & 12 deletions src/sage/modular/arithgroup/tests.py
Expand Up @@ -12,6 +12,7 @@
# http://www.gnu.org/licenses/
#
################################################################################
from __future__ import print_function

from arithgroup_perm import ArithmeticSubgroup_Permutation, EvenArithmeticSubgroup_Permutation, OddArithmeticSubgroup_Permutation
from sage.modular.arithgroup.all import Gamma, Gamma0, Gamma1, GammaH
Expand Down Expand Up @@ -152,9 +153,8 @@ def _do(self, name):
test_random
...
"""

print "test_%s"%name
Test.__dict__["test_%s"%name](self)
print("test_%s" % name)
Test.__dict__["test_%s" % name](self)

def random(self, seconds=0):
"""
Expand Down Expand Up @@ -202,7 +202,7 @@ def test(self, name, seconds=0):
s += " (will stop after about %s seconds)"%seconds
t = cputime()
self._do(name)
print "\ttime=%s\telapsed=%s"%(cputime(t),cputime(total))
print("\ttime=%s\telapsed=%s" % (cputime(t), cputime(total)))
n += 1

def test_random(self):
Expand All @@ -217,7 +217,7 @@ def test_random(self):
"""
tests = [a for a in Test.__dict__.keys() if a[:5] == "test_" and a != "test_random"]
name = prandom.choice(tests)
print "Doing random test %s"%name
print("Doing random test %s" % name)
Test.__dict__[name](self)

def test_relabel(self):
Expand Down Expand Up @@ -264,13 +264,13 @@ def test_relabel(self):
GG.relabel()

for elt in ['_S2','_S3','_L','_R']:
if getattr(G,elt) != getattr(GG,elt):
print "s2 = %s" %str(s2)
print "s3 = %s" %str(s3)
print "ss2 = %s" %str(ss2)
print "ss3 = %s" %str(ss3)
print "pp = %s" %str(pp)
raise AssertionError("%s does not coincide" %elt)
if getattr(G, elt) != getattr(GG, elt):
print("s2 = %s" % str(s2))
print("s3 = %s" % str(s3))
print("ss2 = %s" % str(ss2))
print("ss3 = %s" % str(ss3))
print("pp = %s" % str(pp))
raise AssertionError("%s does not coincide" % elt)

def test_congruence_groups(self):
r"""
Expand Down
97 changes: 48 additions & 49 deletions src/sage/modular/modform/test.py
Expand Up @@ -2,125 +2,124 @@
Run difficult calculations that test the modular forms
functionality.
There's currently no good system for timing these doctests across
all platforms, so I'm turning these all into comments (so that they
aren't counted against are doctest coverage), noting that we should
There is currently no good system for timing these doctests across
all platforms, so I am turning these all into comments (so that they
are not counted against are doctest coverage), noting that we should
use these when (if?) we one day have a good regression testing
system in place. All the functions below have just had the "def"
removed from the beginning of their declaration.
-Craig Citro
system in place.
Craig Citro
from sage.all import *
m=0; t=0; tw=0
pre():
def pre():
global m, t, tw
m = get_memory_usage()
t = cputime()
tw = walltime()
post():
def post():
global m,t
print "total time: %s (wall: %.2f); memory usage diff: %sMB"%(cputime(t),
walltime(tw), get_memory_usage() - m)
print("total time: %s (wall: %.2f); memory usage diff: %sMB"%(cputime(t),
walltime(tw), get_memory_usage() - m))
test1():
def test1():
pre()
for N in range(1,75):
M = ModularForms(N,2)
print M
print M.basis()
print(M)
print(M.basis())
post()
test2():
def test2():
pre()
for N in range(1,30):
M = ModularForms(Gamma1(N),2)
print M
print M.basis()
print(M)
print(M.basis())
post()
test3():
def test3():
pre()
for k in range(2,100):
M = ModularForms(1,k)
print M
print M.basis()
print(M)
print(M.basis())
post()
test4():
def test4():
pre()
for N in range(1,30):
M = ModularForms(N,4, prec=20)
print M
print M.basis()
print(M)
print(M.basis())
post()
test5():
def test5():
pre()
for N in range(1,50):
M = ModularForms(N,2, prec=30)
print M
print M.basis()
print(M)
print(M.basis())
post()
test6():
def test6():
pre()
for N in range(225,230):
M = ModularForms(N,2,prec=40)
print M
print M.basis()
print(M)
print(M.basis())
post()
test7():
def test7():
pre()
for k in range(2,30):
M = ModularForms(2,k)
print M
print M.basis()
print(M)
print(M.basis())
post()
test8():
def test8():
pre()
for k in range(2,20):
M = ModularForms(Gamma1(3),k)
print M
print M.basis()
print(M)
print(M.basis())
post()
test9():
def test9():
pre()
for k in range(2,11):
M = ModularForms(Gamma1(8),k)
M.set_precision(M.dimension()+2)
print M
print M.basis()
print(M)
print(M.basis())
post()
test10():
def test10():
pre()
for k in range(2,11):
M = ModularForms(k,k)
M.set_precision(M.dimension()+2)
print M
print M.basis()
print(M)
print(M.basis())
post()
test11():
def test11():
pre()
for i in range(100):
M = ModularForms(randint(1,100),randint(2,6))
print M
print M.basis()
print(M)
print(M.basis())
post()
test12():
def test12():
S = CuspForms(23,2)
print S
print S.hecke_operator(2)
print S.hecke_operator(2).matrix()
print(S)
print(S.hecke_operator(2))
print(S.hecke_operator(2).matrix())
"""

23 changes: 11 additions & 12 deletions src/sage/modular/modsym/tests.py
Expand Up @@ -24,7 +24,7 @@
#
# http://www.gnu.org/licenses/
#*****************************************************************************

from __future__ import print_function

import random

Expand Down Expand Up @@ -105,15 +105,15 @@ def _modular_symbols_space(self):
else:
which = random.randrange(0,3)
if which == 0:
print "gamma0"
print("gamma0")
M = self._modular_symbols_space_gamma0()
elif which == 1:
print "gamma1"
print("gamma1")
M = self._modular_symbols_space_gamma1()
else:
print "character"
print("character")
M = self._modular_symbols_space_character()
print "\t",M
print("\t", M)
return M

def _level_weight_sign(self):
Expand All @@ -129,8 +129,8 @@ def _level_weight_sign(self):
"""
level = random.choice(self.levels)
weight = random.choice(self.weights)
sign = random.choice([-1,0,1])
print "level = %s, weight = %s, sign = %s"%(level,weight,sign)
sign = random.choice([-1, 0, 1])
print("level = %s, weight = %s, sign = %s" % (level, weight, sign))
return level, weight, sign

def _modular_symbols_space_gamma0(self):
Expand Down Expand Up @@ -193,8 +193,8 @@ def _do(self, name):
test_random
...
"""
print "test_%s"%name
Test.__dict__["test_%s"%name](self)
print("test_%s" % name)
Test.__dict__["test_%s" % name](self)

#################################################################
# The tests
Expand Down Expand Up @@ -234,7 +234,7 @@ def test(self, name, seconds=0):
s += " (will stop after about %s seconds)"%seconds
t = cputime()
self._do(name)
print "\ttime=%s\telapsed=%s"%(cputime(t),cputime(total))
print("\ttime=%s\telapsed=%s" % (cputime(t), cputime(total)))
n += 1

def test_cs_dimension(self):
Expand Down Expand Up @@ -330,6 +330,5 @@ def test_random(self):
"""
tests = [a for a in Test.__dict__.keys() if a[:5] == "test_" and a != "test_random"]
name = random.choice(tests)
print "Doing random test %s"%name
print("Doing random test %s" % name)
Test.__dict__[name](self)

13 changes: 7 additions & 6 deletions src/sage/quadratic_forms/genera/genus.py
Expand Up @@ -8,6 +8,7 @@
#
# http://www.gnu.org/licenses/
#*****************************************************************************
from __future__ import print_function

from sage.misc.all import prod
from sage.arith.all import LCM
Expand Down Expand Up @@ -743,8 +744,8 @@ def split_odd(A):
B = C*A*C.transpose()
even, j = is_even_matrix(B)
if even:
print "B:"
print B
print("B:")
print(B)
raise RuntimeError("The matrix A does not admit a non-even splitting.")
return u, B

Expand Down Expand Up @@ -844,8 +845,8 @@ def two_adic_symbol(A, val):
# d0 = ZZ(A_8.determinant()) # no determinant over Z/8Z
d0 = ZZ(R_8(MatrixSpace(ZZ,n)(A_8).determinant()))
if d0 == 0: ## SANITY CHECK: The mod 8 determinant shouldn't be zero.
print "A:"
print A
print("A:")
print(A)
assert False
even, i = is_even_matrix(A_2) ## Determine whether the matrix is even or odd.
if even:
Expand All @@ -866,8 +867,8 @@ def two_adic_symbol(A, val):
# d0 = A_8.det() # no determinant over Z/8Z
d0 = ZZ(R_8(MatrixSpace(ZZ,n0,n0)(A_8).determinant()))
if d0 == 0:
print "A:"
print A_new
print("A:")
print(A_new)
assert False
even, i = is_even_matrix(A_new)
if even:
Expand Down
Expand Up @@ -8,6 +8,7 @@
## by a quadratic form at a prime (possibly subject to additional
## congruence conditions).
##########################################################################
from __future__ import print_function

from copy import deepcopy

Expand Down Expand Up @@ -438,7 +439,6 @@ def local_good_density_congruence(self, p, m, Zvec=None, NZvec=None):
return self.local_good_density_congruence_odd(p, m, Zvec, NZvec)

if (p == 2):
#print "\n Using the (p=2) Local_Good_Density_Even routine! \n"
return self.local_good_density_congruence_even(m, Zvec, NZvec)

raise RuntimeError("\n Error in Local_Good_Density: The 'prime' p = " + str(p) + " is < 2. \n")
Expand Down Expand Up @@ -671,8 +671,8 @@ def local_badI_density_congruence(self, p, m, Zvec=None, NZvec=None):

## Check that the form is primitive... WHY DO WE NEED TO DO THIS?!?
if (S0 == []):
print " Using Q = " + str(self)
print " and p = " + str(p)
print(" Using Q = " + str(self))
print(" and p = " + str(p))
raise RuntimeError("Oops! The form is not primitive!")


Expand Down Expand Up @@ -847,8 +847,8 @@ def local_badII_density_congruence(self, p, m, Zvec=None, NZvec=None):

## Check that the form is primitive... WHY IS THIS NECESSARY?
if (S0 == []):
print " Using Q = " + str(self)
print " and p = " + str(p)
print(" Using Q = " + str(self))
print(" and p = " + str(p))
raise RuntimeError("Oops! The form is not primitive!")


Expand Down
Expand Up @@ -10,7 +10,7 @@
## Copyright by Jonathan Hanke 2007 <jonhanke@gmail.com>
########################################################################
# python3
from __future__ import division
from __future__ import division, print_function

import copy

Expand Down Expand Up @@ -195,7 +195,7 @@ def Pall_mass_density_at_odd_prime(self, p):
p_mass = prod(jordan_mass_list)
p_mass *= 2**(s-1) * p**nu

print jordan_list, MJL, jordan_mass_list, p_mass
print(jordan_list, MJL, jordan_mass_list, p_mass)

## Return the result
return p_mass
Expand Down

0 comments on commit 5ef5316

Please sign in to comment.