getfem-commits
[Top][All Lists]

## [Getfem-commits] (no subject)

 From: Yves Renard Subject: [Getfem-commits] (no subject) Date: Mon, 18 Jun 2018 15:28:53 -0400 (EDT)

```branch: master
commit ffcd11d59556d3d89071275a73076d61a7c14e4a
Date:   Mon Jun 18 21:27:36 2018 +0200

For compatibility with python3
---
interface/tests/python/check_asm.py | 130 ++++++++++++++++++------------------
1 file changed, 65 insertions(+), 65 deletions(-)

diff --git a/interface/tests/python/check_asm.py
b/interface/tests/python/check_asm.py
index fa2e4f4..317f709 100644
--- a/interface/tests/python/check_asm.py
+++ b/interface/tests/python/check_asm.py
@@ -59,180 +59,180 @@ md.set_variable('w', W)

# Simple test on the integral of u
result = gf.asm('generic', mim, 0, "u", -1, md)
-if (abs(result-1) > 1e-8) : print "Bad value"; exit(1)
+if (abs(result-1) > 1e-8) : print("Bad value"); exit(1)

# Single contraction and comparison with Trace
result1 = gf.asm('generic', mim, 0,
"Def P(a):=a*(a'); Contract(P(Grad_v), 1, 2)", -1, md)
result2 = gf.asm('generic', mim, 0,
-if (abs(result1-result2) > 1e-8) : print "Bad value"; exit(1)
+if (abs(result1-result2) > 1e-8) : print("Bad value"); exit(1)

# Constant order 3 tensor contraction test
result1 = gf.asm('generic', mim, 0,
"Contract([[[1,1],[2,2]],[[1,1],[2,2]]], 1, 2)", -1, md)
result2 = np.array([3., 3.]);
-if (np.linalg.norm(result1-result2) > 1e-8) : print "Bad value"; exit(1)
+if (np.linalg.norm(result1-result2) > 1e-8) : print("Bad value"); exit(1)

# Single contraction, comparison with "*"
-if (np.linalg.norm(result1-result2) > 1e-8) : print "Bad value"; exit(1)
+if (np.linalg.norm(result1-result2) > 1e-8) : print("Bad value"); exit(1)

# Double contraction order one expression, comparison with ":"
result1 = gf.asm('generic', mim, 1,
-if (np.linalg.norm(result1-result2) > 1e-8) : print "Bad value"; exit(1)
+if (np.linalg.norm(result1-result2) > 1e-8) : print("Bad value"); exit(1)

# Double contraction order two expression, comparison with ":"
result1 = gf.asm('generic', mim, 2,
if (np.linalg.norm(result1.full()-result2.full()) > 1e-8) :
result1 = gf.asm('generic', mim, 2,
if (np.linalg.norm(result1.full()-result2.full()) > 1e-8) :

mim, 2, md)

-print res
+print(res)

if (res != "(Contract([[1,0],[0,1]], 1, 2, Hess_w, 1, 2))"):

if (res !=

if (res !=

-print '\nAssembly string "Grad([u,u; 2,1; u,u])" gives:'
+print('\nAssembly string "Grad([u,u; 2,1; u,u])" gives:')
res = gf.asm('expression analysis', "Grad([u,u; 2,1; u,u])",  mim, 2, md)
if (res !=

res = gf.asm('expression analysis', "Grad([[u,2,u],[u,1,u]])",  mim, 2, md)
if (res !=

res = gf.asm('expression analysis', "Grad([u,u])",  mim, 2, md)

2, md)
if (res != "(Swap_indices(Index_move_last(Hess_w, 1), 2, 3))"):

2))", mim, 2, md)
Hess_w, 1, 2))"):

-str = "Grad(sin(u))"; print '\nAssembly string "%s" gives:' % str
+str = "Grad(sin(u))"; print('\nAssembly string "%s" gives:' % str)
res = gf.asm('expression analysis', str,  mim, 2, md)

res = gf.asm('expression analysis', str,  mim, 2, md)

-str = "Grad(min(v, 2*v))"; print '\nAssembly string "%s" gives:' % str
+str = "Grad(min(v, 2*v))"; print('\nAssembly string "%s" gives:' % str)
res = gf.asm('expression analysis', str,  mim, 0, md)

-str = "Grad(Norm(v))"; print '\nAssembly string "%s" gives:' % str
+str = "Grad(Norm(v))"; print('\nAssembly string "%s" gives:' % str)
res = gf.asm('expression analysis', str,  mim, 1, md)

-str = "Diff((v*u).v, v)"; print '\nAssembly string "%s" gives:' % str
+str = "Diff((v*u).v, v)"; print('\nAssembly string "%s" gives:' % str)
res = gf.asm('expression analysis', str,  mim, 2, md)

-str = "Diff((v*u).v, v, [0, 1, 3])"; print '\nAssembly string "%s" gives:' %
str
+str = "Diff((v*u).v,v,[0, 1, 3])"; print('\nAssembly string "%s" gives:' % str)
res = gf.asm('expression analysis', str,  mim, 2, md)
if (res != "((v.([0,1,3]*u))+((v*u).[0,1,3]))"):

-str = "Diff((w*u).Grad_u, u, 3)"; print '\nAssembly string "%s" gives:' % str
+str = "Diff((w*u).Grad_u, u, 3)"; print('\nAssembly string "%s" gives:' % str)
res = gf.asm('expression analysis', str,  mim, 2, md)

-str = "Diff((w*u).Grad_u, u, X.w)"; print '\nAssembly string "%s" gives:' % str
+str = "Diff((w*u).Grad_u, u, X.w)"; print('\nAssembly string "%s" gives:' %
str)
res = gf.asm('expression analysis', str,  mim, 2, md)

-str = "Diff((w*u).Grad_u, u, X(1))"; print '\nAssembly string "%s" gives:' %
str
+str = "Diff((w*u).Grad_u,u,X(1))"; print('\nAssembly string "%s" gives:' % str)
res = gf.asm('expression analysis', str,  mim, 2, md)

"%s" gives:' % str
"%s" gives:' % str)
res = gf.asm('expression analysis', str,  mim, 2, md)

str