getfem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-commits] (no subject)


From: Tetsuo Koyama
Subject: [Getfem-commits] (no subject)
Date: Thu, 29 Nov 2018 06:58:26 -0500 (EST)

branch: devel-tetsuo-2to3check
commit 4fe9963c6583fadb178abc07d1e4e06809b1363d
Author: Tetsuo Koyama <address@hidden>
Date:   Thu Nov 29 20:57:17 2018 +0900

    Fix python script by 2to3
---
 interface/tests/python/check_levelset.py           |  2 +-
 interface/tests/python/demo_dynamic_contact_1D.py  | 38 +++++++++++-----------
 .../tests/python/demo_large_sliding_contact.py     |  2 +-
 interface/tests/python/demo_mortar.py              |  2 +-
 interface/tests/python/demo_plasticity.py          |  4 +--
 interface/tests/python/demo_stokes_3D_tank.py      |  4 +--
 interface/tests/python/demo_tripod.py              |  4 +--
 interface/tests/python/demo_tripod_alt.py          |  4 +--
 interface/tests/python/demo_wave.py                |  4 +--
 interface/tests/python/getfem_tvtk.py              | 22 ++++++-------
 10 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/interface/tests/python/check_levelset.py 
b/interface/tests/python/check_levelset.py
index 7c9d5fc..0f86843 100644
--- a/interface/tests/python/check_levelset.py
+++ b/interface/tests/python/check_levelset.py
@@ -82,7 +82,7 @@ if True:
   m.export_to_pos('m.pos')
 else:
   sl = gf.Slice(('none',), mls, 1);
-  for i in xrange(nbd):
+  for i in range(nbd):
     U = np.zeros(nbd)
     U[i] = 1
     sl.export_to_pos('slU'+str(i)+'.pos',mfls,U,'U'+str(i))
diff --git a/interface/tests/python/demo_dynamic_contact_1D.py 
b/interface/tests/python/demo_dynamic_contact_1D.py
index 567f4c3..ee34110 100644
--- a/interface/tests/python/demo_dynamic_contact_1D.py
+++ b/interface/tests/python/demo_dynamic_contact_1D.py
@@ -73,15 +73,15 @@ do_export_in_files = False;
 # Read optional parameters on the command line 
 for i in range(1,len(sys.argv)): exec(sys.argv[i])
 
-print "Begin experiment for",
-if    (version == 0): print "Pure Signorini contact",
-elif  (version == 1): print "Paoli-Schatzman scheme",
-elif  (version == 2): print "Penalized contact",
-elif  (version == 3): print "Nitsche's method",
-elif  (version == 4): print "Taylor-Flanagan method",
-print " in P%d, with NX = %d, dt = %g" % (u_degree,NX, dt)
+print("Begin experiment for", end=' ')
+if    (version == 0): print("Pure Signorini contact", end=' ')
+elif  (version == 1): print("Paoli-Schatzman scheme", end=' ')
+elif  (version == 2): print("Penalized contact", end=' ')
+elif  (version == 3): print("Nitsche's method", end=' ')
+elif  (version == 4): print("Taylor-Flanagan method", end=' ')
+print(" in P%d, with NX = %d, dt = %g" % (u_degree,NX, dt))
 
-if (version == 4 and beta != 0): print 'Incompatibility'; exit(1)
+if (version == 4 and beta != 0): print('Incompatibility'); exit(1)
 
 # Deduced parameters
 h = 1./NX
@@ -90,8 +90,8 @@ NT = TT.size
 dt_max_approx = h/(2* u_degree);
 if (version == 2): dt_max_approx = min(dt_max_approx, 2*h/(gamma0_P))
 if (version == 3): dt_max_approx = min(dt_max_approx, 2*h/(gamma0_N))
-print 'Approximative dt_max for CFL :', dt_max_approx
-if (beta == 0 and dt > dt_max_approx): print 'Time step too large'; exit(1)
+print('Approximative dt_max for CFL :', dt_max_approx)
+if (beta == 0 and dt > dt_max_approx): print('Time step too large'); exit(1)
 
 # Exact solution. The solution is periodic of period 3
 # Return the displacement (d=0), x derivative (d=1) or time derivative (d=2)
@@ -377,8 +377,8 @@ for nit in range(0, NT):
     # Draw the approximated and exact solutions
     if (t >= tplot-(1e-10)):
         tplot += dtplot;
-        print ("Time %3f"% t), "/", T,
-        print (" Energy %7f" % E), (" Mech energy %7f" % E_org)
+        print(("Time %3f"% t), "/", T, end=' ')
+        print((" Energy %7f" % E), (" Mech energy %7f" % E_org))
         
         if (do_inter_plot):
             UUex = np.copy(Xdraw)
@@ -407,23 +407,23 @@ for nit in range(0, NT):
     
 # print the main relative errors
 LinfL2u = np.amax(store_UL2) / np.amax(store_UL2_ex)
-print 'L^\intfy(0,T,L^2)-norm of the error on u: ', LinfL2u
+print('L^\intfy(0,T,L^2)-norm of the error on u: ', LinfL2u)
 LinfH1u = np.amax(store_UH1) / np.amax(store_UH1_ex)
-print 'L^\intfy(0,T,H^1)-norm of the error on u: ', LinfH1u
+print('L^\intfy(0,T,H^1)-norm of the error on u: ', LinfH1u)
 LinfL2v = np.amax(store_VL2) / np.amax(store_VL2_ex)
-print 'L^\intfy(0,T,L^2)-norm of the error on v: ', LinfL2v
+print('L^\intfy(0,T,L^2)-norm of the error on v: ', LinfL2v)
 Nor = np.sqrt(np.sum(np.square(store_UL2_ex))*dt)
 L2L2u = np.sqrt(np.sum(np.square(store_UL2))*dt) / Nor
-print 'L^2(0,T,L^2)-norm of the error on u: ', L2L2u
+print('L^2(0,T,L^2)-norm of the error on u: ', L2L2u)
 Nor = np.sqrt(np.sum(np.square(store_UH1_ex))*dt)
 L2H1u = np.sqrt(np.sum(np.square(store_UH1))*dt) / Nor
-print 'L^2(0,T,H^1)-norm of the error on u: ', L2H1u
+print('L^2(0,T,H^1)-norm of the error on u: ', L2H1u)
 Nor = np.sqrt(np.sum(np.square(store_VL2_ex))*dt)
 L2L2v = np.sqrt(np.sum(np.square(store_VL2))*dt) / Nor
-print 'L^2(0,T)-norm of the error on v: ', L2L2v
+print('L^2(0,T)-norm of the error on v: ', L2L2v)
 Nor = np.sqrt(np.sum(np.square(store_s0_ex))*dt)
 L2sn = np.sqrt(np.sum(np.square(store_s0-store_s0_ex))*dt) / Nor
-print 'L^2(0,T)-norm of the error on contact stress: ', L2sn
+print('L^2(0,T)-norm of the error on contact stress: ', L2sn)
 
 
 if (do_export_in_files):
diff --git a/interface/tests/python/demo_large_sliding_contact.py 
b/interface/tests/python/demo_large_sliding_contact.py
index be4b741..4576514 100644
--- a/interface/tests/python/demo_large_sliding_contact.py
+++ b/interface/tests/python/demo_large_sliding_contact.py
@@ -113,7 +113,7 @@ else:
    mesh1.set_region(CONTACT_BOUNDARY1, contact_boundary)
    P = mesh1.pts()  # get list of mesh points coordinates
    ctop = (P[N-1,:] > 39.999)  # find those on top of the object
-   pidtop = np.compress(ctop, range(0, mesh1.nbpts()))
+   pidtop = np.compress(ctop, list(range(0, mesh1.nbpts())))
    ftop = mesh1.faces_from_pid(pidtop)
    mesh1.set_region(DIRICHLET_BOUNDARY1, ftop)
 
diff --git a/interface/tests/python/demo_mortar.py 
b/interface/tests/python/demo_mortar.py
index 045911e..43e6e4d 100644
--- a/interface/tests/python/demo_mortar.py
+++ b/interface/tests/python/demo_mortar.py
@@ -90,7 +90,7 @@ indm = mfm.basic_dof_on_region(MORTAR_BOUNDARY_OUT)
 expr = 'M(#1,#2)+=comp(vBase(#1).vBase(#2))(:,i,:,i)'
 M =   gf.asm_boundary(MORTAR_BOUNDARY_IN, expr, mim, mfm, mfu)
 M = M-gf.asm_boundary(MORTAR_BOUNDARY_OUT, expr, mim, mfm, mfu)
-M = gf.Spmat('copy', M, indm, range(M.size()[1]))
+M = gf.Spmat('copy', M, indm, list(range(M.size()[1])))
 
 md = gf.Model('real')
 md.add_fem_variable('u', mfu);
diff --git a/interface/tests/python/demo_plasticity.py 
b/interface/tests/python/demo_plasticity.py
index 2307fcc..d411aae 100644
--- a/interface/tests/python/demo_plasticity.py
+++ b/interface/tests/python/demo_plasticity.py
@@ -65,8 +65,8 @@ Mu=80769
 sigma_y=4000
 
 P=m.pts()
-pidleft=np.compress((abs(P[0,:])<1e-6), range(0, m.nbpts()))
-pidright=np.compress((abs(P[0,:] - L)<1e-6), range(0, m.nbpts()))
+pidleft=np.compress((abs(P[0,:])<1e-6), list(range(0, m.nbpts())))
+pidright=np.compress((abs(P[0,:] - L)<1e-6), list(range(0, m.nbpts())))
 
 fleft  = m.faces_from_pid(pidleft)
 fright = m.faces_from_pid(pidright)
diff --git a/interface/tests/python/demo_stokes_3D_tank.py 
b/interface/tests/python/demo_stokes_3D_tank.py
index 1567fba..603b52d 100644
--- a/interface/tests/python/demo_stokes_3D_tank.py
+++ b/interface/tests/python/demo_stokes_3D_tank.py
@@ -46,7 +46,7 @@ print('nbcvs=%d, nbpts=%d, qdim=%d, fem = %s, nbdof=%d' % \
 
 
 P=m.pts()
-r = range(0, m.nbpts());
+r = list(range(0, m.nbpts()));
 INpid=compress(abs(P[0,:]+25) < 1e-4, r)
 OUTpid=compress(abs(P[0,:]-25) < 1e-4, r)
 TOPpid=compress(abs(P[2,:]-20) < 1e-4, r)
@@ -73,7 +73,7 @@ md.add_fem_variable('p', mfp);
 md.add_linear_incompressibility_brick(mim, 'u', 'p');
 md.add_variable('mult_spec', 1);
 M = Spmat('empty', 1, mfp.nbdof());
-M.add(range(1), range(mfp.nbdof()), ones((1, mfp.nbdof())));
+M.add(list(range(1)), list(range(mfp.nbdof())), ones((1, mfp.nbdof())));
 md.add_constraint_with_multipliers('p', 'mult_spec', M, [0]);
 md.add_initialized_data('NeumannData', [0, -10, 0]);
 md.add_source_term_brick(mim, 'u', 'NeumannData', 1);
diff --git a/interface/tests/python/demo_tripod.py 
b/interface/tests/python/demo_tripod.py
index 158911a..4be1e72 100644
--- a/interface/tests/python/demo_tripod.py
+++ b/interface/tests/python/demo_tripod.py
@@ -62,8 +62,8 @@ P=m.pts()
 print('test', P[1,:])
 ctop=(abs(P[1,:] - 13) < 1e-6)
 cbot=(abs(P[1,:] + 10) < 1e-6)
-pidtop=np.compress(ctop, range(0, m.nbpts()))
-pidbot=np.compress(cbot, range(0, m.nbpts()))
+pidtop=np.compress(ctop, list(range(0, m.nbpts())))
+pidbot=np.compress(cbot, list(range(0, m.nbpts())))
 
 ftop=m.faces_from_pid(pidtop)
 fbot=m.faces_from_pid(pidbot)
diff --git a/interface/tests/python/demo_tripod_alt.py 
b/interface/tests/python/demo_tripod_alt.py
index 50ca518..8f39ec1 100644
--- a/interface/tests/python/demo_tripod_alt.py
+++ b/interface/tests/python/demo_tripod_alt.py
@@ -50,8 +50,8 @@ P=m.pts()
 
 ctop=(abs(P[1,:] - 13) < 1e-6);
 cbot=(abs(P[1,:] + 10) < 1e-6);
-pidtop=compress(ctop, range(0, m.nbpts()))
-pidbot=compress(cbot, range(0, m.nbpts()))
+pidtop=compress(ctop, list(range(0, m.nbpts())))
+pidbot=compress(cbot, list(range(0, m.nbpts())))
 
 ftop=m.faces_from_pid(pidtop)
 fbot=m.faces_from_pid(pidbot)
diff --git a/interface/tests/python/demo_wave.py 
b/interface/tests/python/demo_wave.py
index ec76aa9..46702cc 100644
--- a/interface/tests/python/demo_wave.py
+++ b/interface/tests/python/demo_wave.py
@@ -52,8 +52,8 @@ P=m.pts(); # get list of mesh points coordinates
 Psqr=sum(P*P, 0);
 cobj=(Psqr < 1*1+1e-6);
 cout=(Psqr > 10*10-1e-2);
-pidobj=compress(cobj, range(0, m.nbpts()))
-pidout=compress(cout, range(0, m.nbpts()))
+pidobj=compress(cobj, list(range(0, m.nbpts())))
+pidout=compress(cout, list(range(0, m.nbpts())))
 fobj=m.faces_from_pid(pidobj)
 fout=m.faces_from_pid(pidout)
 ROBIN_BOUNDARY = 1
diff --git a/interface/tests/python/getfem_tvtk.py 
b/interface/tests/python/getfem_tvtk.py
index 9351738..3c17071 100644
--- a/interface/tests/python/getfem_tvtk.py
+++ b/interface/tests/python/getfem_tvtk.py
@@ -173,7 +173,7 @@ class FigureItem:
             elif (len(data) == 1):
                 U = data[0]
             else:
-                raise Exception, "wrong data tuple.."
+                raise Exception("wrong data tuple..")
         else:
             U = data
         if mf is not None:
@@ -196,7 +196,7 @@ class FigureItem:
         d = self.dfield_on_slice(vdata)
         n = self.sl.nbpts()
         if d.size % n != 0:
-            raise Exception, "non consistent dimension for data"
+            raise Exception("non consistent dimension for data")
         if d.size > n:
             d = d.transpose()
             d.shape = (n,-1)
@@ -230,7 +230,7 @@ class FigureItem:
         elif isinstance(c, tvtk.LookupTable):
             lut = c
         else:
-            raise Exception, "expected a string or a tvtk.LookupTable"
+            raise Exception("expected a string or a tvtk.LookupTable")
         self.lookup_table = lut
         if (self.mapper is not None):
             self.mapper.lookup_table = self.lookup_table
@@ -276,7 +276,7 @@ class FigureItem:
                 elif self.glyph_name == 'cube':
                     glyph.source = tvtk.CubeSource().output
                 else:
-                    raise Exception, "Unknown glyph name.."
+                    raise Exception("Unknown glyph name..")
                 #glyph.scaling = 1
                 #glyph.scale_factor = self.glyph_scale_factor
                 data = glyph.output
@@ -394,16 +394,16 @@ class Figure:
     def show_mesh_fem(self, mf, **args):
         it = FigureItem(self)
         it.build_from_mesh(mf.linked_mesh(), **args)
-        if args.has_key('deformation'):
+        if 'deformation' in args:
             it.deformation_from_mf(args.get('deformation_mf',mf),
                                    args['deformation'],
                                    args.get('deformation_scale','10%'));
-        if args.has_key('data'):
+        if 'data' in args:
             it.set_scalar_data(args.get('data'),
                                args.get('scalar_label', 'data'));
         it.set_scalar_bar(args.get('scalar_bar', False))
 
-        if args.has_key('vdata'):
+        if 'vdata' in args:
             it.set_vector_data(args.get('vdata'))
 
         self.actors += it.vtk_actors()
@@ -415,13 +415,13 @@ class Figure:
         it = FigureItem(self)
         it.build_from_slice(sl, **args)
 
-        if args.has_key('data'):
+        if 'data' in args:
             it.set_scalar_data(args.get('data'),
                                args.get('scalar_label', 'data'));
 
         it.set_scalar_bar(args.get('scalar_bar', False))
 
-        if args.has_key('vdata'):
+        if 'vdata' in args:
             it.set_vector_data(args.get('vdata'))
 
         self.actors += it.vtk_actors()
@@ -437,7 +437,7 @@ class Figure:
                 for i in self.items:
                     i.scalar_range(*args)
         else:
-            raise Exception, "plot something before changing its scalar range!"
+            raise Exception("plot something before changing its scalar range!")
 
 ##    def scalar_bar(self):
 ##        if len(self.items):
@@ -454,7 +454,7 @@ class Figure:
         elif isinstance(mf, getfem.Slice):
             self.show_slice(mf, **args)
         else:
-            raise TypeError, "argument must be a drawable getfem object"
+            raise TypeError("argument must be a drawable getfem object")
     def loop(self):
         for a in self.actors:
             self.renderer.add_actor(a)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]