diff --git a/examples/group_energy.py b/examples/group_energy.py index 193b867..42703bc 100644 --- a/examples/group_energy.py +++ b/examples/group_energy.py @@ -5,6 +5,8 @@ # return distance sq between 2 atoms with PBC +from __future__ import absolute_import + def distance(box,x1,y1,z1,x2,y2,z2): delx = x2 - x1 @@ -37,7 +39,7 @@ def distance(box,x1,y1,z1,x2,y2,z2): # main script if len(argv) < 3: - raise StandardError,"group_energy.py data.file dump.file1 dump.file2 ..." + raise Exception("group_energy.py data.file dump.file1 dump.file2 ...") dt = data(argv[1]) # data file q = dt.get("Atoms",4) @@ -75,32 +77,32 @@ while 1: d.aselect.test("$id >= 1 and $id <= 7243 or $id >= 7274 and $id <= 14283", time) id2,type2,x2,y2,z2 = d.vecs(time,"id","type","x","y","z") - id1 = map(int,id1) - id2 = map(int,id2) - type1 = map(int,type1) - type2 = map(int,type2) + id1 = list(map(int,id1)) + id2 = list(map(int,id2)) + type1 = list(map(int,type1)) + type2 = list(map(int,type2)) n1 = len(type1) n2 = len(type2) - for i in xrange(n1): + for i in range(n1): id1[i] -= 1 type1[i] -= 1 - for i in xrange(n2): + for i in range(n2): id2[i] -= 1 type2[i] -= 1 e_coul_sum = 0.0 e_vdwl_sum = 0.0 - for i in xrange(n1): + for i in range(n1): typei = type1[i] qi = q[id1[i]] - for j in xrange(n2): + for j in range(n2): rsq = distance(box,x1[i],y1[i],z1[i],x2[j],y2[j],z2[j]) if rsq < maxcut_sq: eng_coul,eng_vdwl = p.single(rsq,typei,type2[j],qi,q[id2[j]]) e_coul_sum += eng_coul e_vdwl_sum += eng_vdwl - print "eng_coul = %g at timestep %d" % (e_coul_sum,time) - print "eng_vdwl = %g at timestep %d" % (e_vdwl_sum,time) + print("eng_coul = %g at timestep %d" % (e_coul_sum,time)) + print("eng_vdwl = %g at timestep %d" % (e_vdwl_sum,time)) d.tselect.none() d.tselect.one(time) diff --git a/examples/movie_flow.py b/examples/movie_flow.py index 833220f..9c3078c 100644 --- a/examples/movie_flow.py +++ b/examples/movie_flow.py @@ -1,5 +1,7 @@ # movie of flow around obstacle +from __future__ import absolute_import + d = dump("dump.flow") d.map(1,"id",2,"type",3,"x",4,"y",5,"z",6,"vx",7,"vy") d.set("$ke = sqrt($vx*$vx + $vy*$vy)") @@ -7,8 +9,8 @@ d.spread("vx",100,"color") d.atype = "color" r = raster(d) -r.acol(range(100),["red","red","red","red","yellow","green","blue","purple","purple","purple","purple"]) -r.arad(range(100),0.5) +r.acol(list(range(100)),["red","red","red","red","yellow","green","blue","purple","purple","purple","purple"]) +r.arad(list(range(100)),0.5) r.rotate(0,-90) r.zoom(1.5) r.file = "flow" diff --git a/examples/movie_melt.py b/examples/movie_melt.py index 9574c64..9fbe7f8 100644 --- a/examples/movie_melt.py +++ b/examples/movie_melt.py @@ -1,6 +1,6 @@ # movie of melting LJ solid -a = dump("dump.melt") +a = dump("files/dump.melt") a.tselect.test("$t == 0") a.scale() a.set("$ix = int($x * 4)") diff --git a/examples/movie_micelle.py b/examples/movie_micelle.py index 00f60df..50ca249 100644 --- a/examples/movie_micelle.py +++ b/examples/movie_micelle.py @@ -1,10 +1,12 @@ # movie of self-assembling micelles -d = dump("dump.micelle") +from __future__ import absolute_import + +d = dump("files/dump.micelle") s = svg(d) s.acol([1,2,3,4],["blue","red","cyan","yellow"]) -s.arad(range(4),0.5) +s.arad(list(range(4)),0.5) s.zoom(1.5) s.file = "micelle" diff --git a/examples/movie_peptide.py b/examples/movie_peptide.py index 376f4ea..147ba8a 100644 --- a/examples/movie_peptide.py +++ b/examples/movie_peptide.py @@ -1,8 +1,8 @@ # movie of solvated peptide data -d = dump("dump.peptide") +d = dump("files/dump.peptide") d.unwrap() -p = pdb("peptide",d) -r.file = "peptide" +p = pdbfile("files/peptide",d) + r = rasmol(p) r.all() diff --git a/examples/movie_tri.py b/examples/movie_tri.py index 9d65a05..3c0d006 100644 --- a/examples/movie_tri.py +++ b/examples/movie_tri.py @@ -1,6 +1,6 @@ # movie of triangular particle data -d = dump("dump.tri") +d = dump("files/dump.tri") d.set("$center = ((int($id)-1)/36+1)*36") d.owrap("center") diff --git a/examples/test_animate.py b/examples/test_animate.py index 6547252..b9b1200 100644 --- a/examples/test_animate.py +++ b/examples/test_animate.py @@ -11,4 +11,4 @@ a.next() a.previous() a.frame(1) -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_bdump.py b/examples/test_bdump.py index 2e25d54..9a1f5cf 100644 --- a/examples/test_bdump.py +++ b/examples/test_bdump.py @@ -9,4 +9,4 @@ dm.extra(b) g = gl(dm) v = vcr(g) -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_cdata.py b/examples/test_cdata.py index 234b145..5e51cdf 100644 --- a/examples/test_cdata.py +++ b/examples/test_cdata.py @@ -31,4 +31,4 @@ c.select("A","B","C","linebox","organelle","nuchalf") g = gl(c) v = vcr(g) -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_cfg.py b/examples/test_cfg.py index 2e55ac0..ad4e107 100644 --- a/examples/test_cfg.py +++ b/examples/test_cfg.py @@ -9,4 +9,4 @@ x.one() x.many() x.single(0,"tmp.single") -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_chain.py b/examples/test_chain.py index 17350da..956cb87 100644 --- a/examples/test_chain.py +++ b/examples/test_chain.py @@ -14,4 +14,4 @@ c.build(10,25) c.write("tmp.data.chain") -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_clog.py b/examples/test_clog.py index 8eeaaa7..346c757 100644 --- a/examples/test_clog.py +++ b/examples/test_clog.py @@ -4,13 +4,13 @@ c = log("files/log.ccell") -print "# of vectors =",c.nvec -print "length of vectors =",c.nlen -print "names of vectors =",c.names +print("# of vectors =",c.nvec) +print("length of vectors =",c.nlen) +print("names of vectors =",c.names) time,a,b = c.get("Step","prey","predator") -print a,b +print(a,b) c.write("tmp.clog") c.write("tmp.clog.two","Step","prey") -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_data.py b/examples/test_data.py index 84040b7..08b8033 100644 --- a/examples/test_data.py +++ b/examples/test_data.py @@ -2,17 +2,19 @@ # requires files/data.micelle and dump.micelle # creates tmp.data +from __future__ import absolute_import + d = data("files/data.micelle") d.map(1,"id",3,"type",4,"x",5,"y",6,"z") coeffs = d.get("Masses") -print "Masses",coeffs +print("Masses",coeffs) x = d.get("Atoms",4) -print "X of 1st atom",x[0] +print("X of 1st atom",x[0]) d.title = "New LAMMPS data file" natoms = d.headers["atoms"] -vec = range(1,natoms+1) +vec = list(range(1,natoms+1)) vec.reverse() d.replace("Atoms",1,vec) @@ -27,4 +29,4 @@ while 1: d.write("tmp.data") -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_dump.py b/examples/test_dump.py index 13abb94..b0efe4e 100644 --- a/examples/test_dump.py +++ b/examples/test_dump.py @@ -27,12 +27,12 @@ d.set("$xyz = $x + $y + $z") d.spread("x",100,"color") d.clone(0,"color") -print "Time",d.time() +print("Time",d.time()) color = d.atom(1,"color") -print "Color of atom 1",color +print("Color of atom 1",color) d.aselect.test("$id <= 10") color = d.vecs(1000,"color") -print "Color of 1st 10 atoms in step 1000",color +print("Color of 1st 10 atoms in step 1000",color) d.atype = "color" @@ -42,13 +42,13 @@ while 1: if flag == -1: break time,box,atoms,bonds,tris,lines = d.viz(index) colors = [atom[1] for atom in atoms] - print time,colors + print(time,colors) d = dump("files/dump.peptide.*",0) while 1: time = d.next() if time < 0: break -print "Incrementally read snaps =",d.nsnaps +print("Incrementally read snaps =",d.nsnaps) -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_ensight.py b/examples/test_ensight.py index 52889da..f240abf 100644 --- a/examples/test_ensight.py +++ b/examples/test_ensight.py @@ -1,4 +1,4 @@ -# simple test of xyz tool +# simple test of ensight tool # requires files/dump.micelle.* # creates tmp*.case, etc @@ -8,4 +8,4 @@ e.one() e.many() e.single(0) -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_gl.py b/examples/test_gl.py index 2ddd1a9..ecaf5b0 100644 --- a/examples/test_gl.py +++ b/examples/test_gl.py @@ -2,6 +2,8 @@ # requires files/dump.kinase # creates tmp*.png +from __future__ import absolute_import + d = dump("files/dump.kinase") g = gl(d) @@ -17,7 +19,7 @@ g.all() from vizinfo import colors g.acol([1,4,6,8,9],["gray","red","blue","green","yellow"]) -g.arad(range(9),0.3) +g.arad(list(range(9)),0.3) #g.label(0.2,0.4,'h',15,"red","test label #1") #g.label(-0.2,-0.4,'h',15,"yellow","test label #2") @@ -25,4 +27,4 @@ g.show(0) g.pan(60,130,1,60,30,0.5) g.all(0,10,0) -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_gnu.py b/examples/test_gnu.py index 125205b..a3394a2 100644 --- a/examples/test_gnu.py +++ b/examples/test_gnu.py @@ -1,17 +1,19 @@ # simple test of gnu tool # creates tmp.eps +from __future__ import absolute_import + g = gnu() g("plot sin(x) with lines") -a = range(10) +a = list(range(10)) b = [3,6,2,5,7,3,6,5,3,1] g.plot(a) g.plot(a,b) g.plot(a,b,b,a) -g.mplot(0,10,2,"tmp",a,b) +g.mplot(2,10,2,"tmp",a,b) g.export("tmp.gnu",a,b) @@ -30,4 +32,4 @@ g.ylog() g.save("tmp") -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_histo.py b/examples/test_histo.py index b4a9f00..4e487ef 100644 --- a/examples/test_histo.py +++ b/examples/test_histo.py @@ -10,4 +10,4 @@ g.ytitle("Particle Count") g.title("Histogram of Particle Density") g.plot(x,y) -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_image.py b/examples/test_image.py index 66a41f5..a5d677a 100644 --- a/examples/test_image.py +++ b/examples/test_image.py @@ -4,6 +4,6 @@ i = image("files/bucky*.png") i.convert("files/bucky*.png","tmp*.gif") i.montage("","files/bucky*.png","tmp*.gif","tmpnew*.png") -i.view("") +i.view("*.png") -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_ldump.py b/examples/test_ldump.py index d360b5f..efccc8b 100644 --- a/examples/test_ldump.py +++ b/examples/test_ldump.py @@ -12,4 +12,4 @@ g.lrad(1,5) g.lcol(1,"green") v = vcr(g) -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_log.py b/examples/test_log.py index 40c1d7c..0016a4e 100644 --- a/examples/test_log.py +++ b/examples/test_log.py @@ -4,13 +4,13 @@ lg = log("files/log.obstacle") -print "# of vectors =",lg.nvec -print "length of vectors =",lg.nlen -print "names of vectors =",lg.names +print("# of vectors =",lg.nvec) +print("length of vectors =",lg.nlen) +print("names of vectors =",lg.names) time,temp,press = lg.get("Step","Temp","Press") -print temp,press +print(temp,press) lg.write("tmp.log") lg.write("tmp.log.two","Step","E_pair") -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_matlab.py b/examples/test_matlab.py index 73b785a..81ad5f3 100644 --- a/examples/test_matlab.py +++ b/examples/test_matlab.py @@ -1,9 +1,11 @@ # simple test of matlab tool # creates tmp.eps +from __future__ import absolute_import + m = matlab() -a = range(10) +a = list(range(10)) b = [3,6,2,5,7,3,6,5,3,1] m.plot(a) @@ -30,4 +32,4 @@ m.ylog() m.save("tmp") -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_mdump.py b/examples/test_mdump.py index 6ba6119..1c8f4bb 100644 --- a/examples/test_mdump.py +++ b/examples/test_mdump.py @@ -12,7 +12,7 @@ m.tselect.all() m.tselect.test("$t >= 100 and $t <= 200") m.delete() -print "Time",m.time() +print("Time",m.time()) m.map(2,"spin") m.etype = "spin" @@ -23,13 +23,13 @@ while 1: if flag == -1: break time,box,atoms,bonds,tris,lines = m.viz(index) colors = [tri[1] for tri in tris] - print time,colors + print(time,colors) m = dump("files/mesh.grain",0) while 1: time = m.next() if time < 0: break -print "Incrementally read snaps =",m.nsnaps +print("Incrementally read snaps =",m.nsnaps) -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_pair.py b/examples/test_pair.py index 530a23b..af3a453 100644 --- a/examples/test_pair.py +++ b/examples/test_pair.py @@ -6,6 +6,6 @@ d = data("files/data.rhodo") p.coeff(d) p.init(8.0,10.0) ev,ec = p.single(5.0,1,2,0.5,-0.5) -print "Energies",ev,ec +print("Energies",ev,ec) -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_patch.py b/examples/test_patch.py index 3df1657..98c1d6a 100644 --- a/examples/test_patch.py +++ b/examples/test_patch.py @@ -7,4 +7,4 @@ p.build(100,"hex2",1,2,3) p.build(50,"tri5",4,5) p.write("tmp.data.patch") -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_pdbfile.py b/examples/test_pdbfile.py index e28594f..9e72e4b 100644 --- a/examples/test_pdbfile.py +++ b/examples/test_pdbfile.py @@ -15,6 +15,6 @@ while 1: p.single(time,"tmp.single") n += 1 -print "Incrementally processed %d PDB files" % n +print("Incrementally processed %d PDB files" % n) -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_plotview.py b/examples/test_plotview.py index 52d8d68..23113ae 100644 --- a/examples/test_plotview.py +++ b/examples/test_plotview.py @@ -15,4 +15,4 @@ p.no(2) p.file("tmp.plotview") p.save() -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_rasmol.py b/examples/test_rasmol.py index eda4c3a..4d1023a 100644 --- a/examples/test_rasmol.py +++ b/examples/test_rasmol.py @@ -8,14 +8,14 @@ p = pdbfile("files/peptide",d) r = rasmol(p) r.file = "tmp" -print "kill image window when ready to contine ..." +print("kill image window when ready to contine ...") r.show(0) r.all() # change RasMol settings, run all() with those settings -print "change RasMol settings as desired, then type 'quit' ..." +print("change RasMol settings as desired, then type 'quit' ...") r.run(0) r.all("tmp.rasmol") -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_raster.py b/examples/test_raster.py index 08b7882..c96c949 100644 --- a/examples/test_raster.py +++ b/examples/test_raster.py @@ -2,6 +2,8 @@ # requires files/dump.kinase # creates tmp*.png +from __future__ import absolute_import + d = dump("files/dump.kinase") r = raster(d) @@ -10,7 +12,7 @@ r.rotate(60,130) r.box(1) r.file = "tmp" -print "kill image window when ready to contine ..." +print("kill image window when ready to contine ...") r.show(0) r.all() a1 = animate("tmp0*png") @@ -18,14 +20,14 @@ a1 = animate("tmp0*png") from vizinfo import colors r.acol([1,4,6,8,9],["gray","red","blue","green","yellow"]) -r.arad(range(9),0.3) +r.arad(list(range(9)),0.3) r.label(0.2,0.4,'h',15,"red","test label #1") r.label(-0.2,-0.4,'h',15,"yellow","test label #2") -print "kill image window when ready to contine ..." +print("kill image window when ready to contine ...") r.show(0) r.pan(60,130,1,60,30,0.5) r.all(0,10,0) a2 = animate("tmp0*png") -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_svg.py b/examples/test_svg.py index 489ad2a..62a1261 100644 --- a/examples/test_svg.py +++ b/examples/test_svg.py @@ -2,6 +2,8 @@ # requires files/dump.kinase # creates tmp*.png +from __future__ import absolute_import + d = dump("files/dump.kinase") s = svg(d) @@ -10,20 +12,20 @@ s.rotate(60,130) s.box(1) s.file = "tmp" -print "kill image window when ready to contine ..." +print("kill image window when ready to contine ...") s.show(0) s.all() from vizinfo import colors s.acol([1,4,6,8,9],["gray","red","blue","green","yellow"]) -s.arad(range(9),0.3) +s.arad(list(range(9)),0.3) s.label(0.2,0.4,'h',15,"red","test label #1") s.label(-0.2,-0.4,'h',15,"yellow","test label #2") -print "kill image window when ready to contine ..." +print("kill image window when ready to contine ...") s.show(0) s.pan(60,130,1,60,30,0.5) s.all(0,10,0) -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_vcr.py b/examples/test_vcr.py index 9daabd2..f1ac45d 100644 --- a/examples/test_vcr.py +++ b/examples/test_vcr.py @@ -13,4 +13,4 @@ v.clipxlo(0.2) v.clipxhi(0.5) v.play() -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_vec.py b/examples/test_vec.py index 6773dd0..967e153 100644 --- a/examples/test_vec.py +++ b/examples/test_vec.py @@ -4,13 +4,13 @@ v = vec("files/vec.txt") -print "# of vectors =",v.nvec -print "length of vectors =",v.nlen -print "names of vectors =",v.names +print("# of vectors =",v.nvec) +print("length of vectors =",v.nlen) +print("names of vectors =",v.names) time,temp,press = v.get(1,"col2",6) -print temp,press +print(temp,press) v.write("tmp.vec") v.write("tmp.vec.two","col1",3) -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_vmd.py b/examples/test_vmd.py index de9da59..e38c7b8 100644 --- a/examples/test_vmd.py +++ b/examples/test_vmd.py @@ -8,4 +8,4 @@ v.rep('VDW') v.new('files/peptide.pdb','pdb') v.flush() -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_vtk.py b/examples/test_vtk.py index 61d78d6..816dff6 100644 --- a/examples/test_vtk.py +++ b/examples/test_vtk.py @@ -8,4 +8,4 @@ v.one() v.many() v.single(0,"tmp.single") -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py") diff --git a/examples/test_xyz.py b/examples/test_xyz.py index aa1d68e..f4a568b 100644 --- a/examples/test_xyz.py +++ b/examples/test_xyz.py @@ -8,4 +8,4 @@ x.one() x.many() x.single(0,"tmp.single") -print "all done ... type CTRL-D to exit Pizza.py" +print("all done ... type CTRL-D to exit Pizza.py")