From a2c7ba73be43e2527d3a5910f3f433c42509ce18 Mon Sep 17 00:00:00 2001 From: Jaron Krogel Date: Thu, 21 Nov 2019 15:45:02 -0500 Subject: [PATCH] nexus: eliminate xrange from lib --- nexus/lib/gaussian_process.py | 4 ++-- nexus/lib/pwscf_analyzer.py | 2 +- nexus/lib/pwscf_input.py | 4 ++-- nexus/lib/vasp_input.py | 20 ++++++++++---------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/nexus/lib/gaussian_process.py b/nexus/lib/gaussian_process.py index f04629584..a95f551f6 100644 --- a/nexus/lib/gaussian_process.py +++ b/nexus/lib/gaussian_process.py @@ -1657,8 +1657,8 @@ class GaussianProcessOptimizer(DevBase): self.vlog('writing parameters to {0}'.format(filepath),n=3) nsamples,nparams = Pset.shape s = '' - for i in xrange(nsamples): - for j in xrange(nparams): + for i in range(nsamples): + for j in range(nparams): s += ' {0: 16.12f}'.format(Pset[i,j]) #end for s += '\n' diff --git a/nexus/lib/pwscf_analyzer.py b/nexus/lib/pwscf_analyzer.py index 1a652684d..960d82b0e 100644 --- a/nexus/lib/pwscf_analyzer.py +++ b/nexus/lib/pwscf_analyzer.py @@ -241,7 +241,7 @@ class PwscfAnalyzer(SimulationAnalyzer): read_kpoints = False read_2pi_alat = False read_rel = False - for i in xrange(len(lines)): + for i in range(len(lines)): l = lines[i] if 'End of self-consistent calculation' in l: # Initialize each time in case a hybrid functional was used diff --git a/nexus/lib/pwscf_input.py b/nexus/lib/pwscf_input.py index f84c224e3..b2d81cd9d 100644 --- a/nexus/lib/pwscf_input.py +++ b/nexus/lib/pwscf_input.py @@ -1624,7 +1624,7 @@ class PwscfInput(SimulationInput): else: relax_directions = ones(s.pos.shape,dtype=int) #end if - for i in xrange(len(s.pos)): + for i in range(len(s.pos)): relax_directions[i,0] = int(not frozen[i,0] and relax_directions[i,0]) relax_directions[i,1] = int(not frozen[i,1] and relax_directions[i,1]) relax_directions[i,2] = int(not frozen[i,2] and relax_directions[i,2]) @@ -1715,7 +1715,7 @@ class PwscfInput(SimulationInput): else: relax_directions = ones(s.pos.shape,dtype=int) #end if - for i in xrange(len(s.pos)): + for i in range(len(s.pos)): relax_directions[i,0] = int(not frozen[i,0] and relax_directions[i,0]) relax_directions[i,1] = int(not frozen[i,1] and relax_directions[i,1]) relax_directions[i,2] = int(not frozen[i,2] and relax_directions[i,2]) diff --git a/nexus/lib/vasp_input.py b/nexus/lib/vasp_input.py index ce94c1d3e..d9ac89715 100644 --- a/nexus/lib/vasp_input.py +++ b/nexus/lib/vasp_input.py @@ -186,7 +186,7 @@ def write_array(arr,same=equality,render=str,max_repeat=3): if count>max_repeat: s += '{0}*{1} '.format(count,render(value)) else: - for i in xrange(count): + for i in range(count): s += render(value)+' ' #end for #end if @@ -257,7 +257,7 @@ def assign_bool_array(a): def vasp_to_nexus_elem(elem,elem_count): syselem=[] for x,count in zip(elem,elem_count): - syselem+=[x for i in xrange(0,count)] + syselem+=[x for i in range(0,count)] #end for return array(syselem) #end def vasp_to_nexus_elem @@ -543,7 +543,7 @@ class VFormattedFile(VFile): def join(self,lines,first_line,last_line): joined = '' - for iline in xrange(first_line,last_line): + for iline in range(first_line,last_line): joined += lines[iline]+' ' #end for joined += lines[last_line] @@ -797,7 +797,7 @@ class Kpoints(VFormattedFile): tokens = lines[tetline+1].split() ntets = int(tokens[0]) tet_volume = float(tokens[1]) - for n in xrange(ntets): + for n in range(ntets): tokens = lines[tetline+2+n].split() self.tetrahedra.append( obj(volume = tet_volume, @@ -842,7 +842,7 @@ class Kpoints(VFormattedFile): text+='bandstructure\n {0}\nline-mode\n'.format(self.kinsert) text+='{0}\n'.format(self.coord) npoints = len(self.kendpoints) - for n in xrange(npoints): + for n in range(npoints): text+=' {0:18.14f} {1:18.14f} {2:18.14f} 1\n'.format(*self.kendpoints[n]) if n!=npoints-1 and n%2==1: text+='\n' @@ -851,7 +851,7 @@ class Kpoints(VFormattedFile): elif self.mode=='explicit': text+='explicit kpoints\n {0}\n'.format(len(self.kpoints)) text+='{0}\n'.format(self.coord) - for n in xrange(len(self.kpoints)): + for n in range(len(self.kpoints)): kp = self.kpoints[n] kw = self.kweights[n] text+=' {0:18.14f} {1:18.14f} {2:18.14f} {3:12.8f}\n'.format(kp[0],kp[1],kp[2],kw) @@ -861,7 +861,7 @@ class Kpoints(VFormattedFile): tets = self.tetrahedra text+='tetrahedra\n' text+=' {0} {1}'.format(ntets,tets[0].volume) - for n in xrange(ntets): + for n in range(ntets): t = tets[n] d = t.degeneracy c = t.corners @@ -1075,7 +1075,7 @@ class Poscar(VFormattedFile): #end for else: bm = self.bool_map - for i in xrange(len(self.pos)): + for i in range(len(self.pos)): p = self.pos[i] d = self.dynamic[i] text += ' {0:18.14f} {1:18.14f} {2:18.14f} {3} {4} {5}\n'.format(p[0],p[1],p[2],bm[d[0]],bm[d[1]],bm[d[2]]) @@ -1138,7 +1138,7 @@ class NebPoscars(Vobj): def write(self,filepath): path = self.get_path(filepath) - for n in xrange(len(self)): + for n in range(len(self)): neb_path = os.path.join(path,str(n).zfill(2)) if not os.path.exists(neb_path): os.mkdir(neb_path) @@ -1523,7 +1523,7 @@ class VaspInput(SimulationInput,Vobj): # create a poscar for each structure and include in input file neb_poscars = NebPoscars() - for n in xrange(len(neb_structures)): + for n in range(len(neb_structures)): neb_poscars[n] = generate_poscar(neb_structures[n]) #end for self.poscar = neb_poscars