Skip to content

Commit

Permalink
run python-modernize xrange fixer on scripts and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
rc committed Jun 20, 2016
1 parent 1f435a4 commit e241d20
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 11 deletions.
1 change: 1 addition & 0 deletions examples/diffusion/sinbc.py
Expand Up @@ -31,6 +31,7 @@
from sfepy.discrete.fem import Mesh, FEDomain
from sfepy.discrete.fem.meshio import UserMeshIO, MeshIO
from sfepy.homogenization.utils import define_box_regions
from six.moves import range

base_mesh = data_dir + '/meshes/elements/2_4_2.mesh'

Expand Down
3 changes: 2 additions & 1 deletion examples/diffusion/time_poisson_interactive.py
Expand Up @@ -19,6 +19,7 @@
"""
from __future__ import absolute_import
import sys
from six.moves import range
sys.path.append('.')
from optparse import OptionParser

Expand Down Expand Up @@ -146,7 +147,7 @@ def main():
domain = FEDomain('domain', mesh)

if options.refine > 0:
for ii in xrange(options.refine):
for ii in range(options.refine):
output('refine %d...' % ii)
domain = domain.refine()
output('... %d nodes %d elements'
Expand Down
1 change: 1 addition & 0 deletions examples/homogenization/perfusion_micro.py
Expand Up @@ -13,6 +13,7 @@
import numpy as nm
from sfepy import data_dir
import six
from six.moves import range

def get_mats(pk, ph, pe, dim):

Expand Down
1 change: 1 addition & 0 deletions examples/linear_elasticity/elastic_contact_planes.py
Expand Up @@ -33,6 +33,7 @@
from __future__ import absolute_import
from sfepy import data_dir
from sfepy.mechanics.matcoefs import stiffness_from_lame
from six.moves import range

filename_mesh = data_dir + '/meshes/3d/cube_medium_hexa.mesh'

Expand Down
3 changes: 2 additions & 1 deletion examples/linear_elasticity/its2D_4.py
Expand Up @@ -40,6 +40,7 @@
from .its2D_1 import *

from sfepy.mechanics.matcoefs import stiffness_from_youngpoisson
from six.moves import range

def stress_strain(out, pb, state, extend=False):
"""
Expand Down Expand Up @@ -68,7 +69,7 @@ def gen_lines(problem):

labels = ['%s -> %s' % (p0, p1) for p0, p1 in zip(ps0, ps1)]
probes = []
for ip in xrange(len(ps0)):
for ip in range(len(ps0)):
p0, p1 = ps0[ip], ps1[ip]
probes.append(LineProbe(p0, p1, n_point))

Expand Down
3 changes: 2 additions & 1 deletion examples/linear_elasticity/its2D_5.py
Expand Up @@ -23,6 +23,7 @@
from sfepy.postprocess.probes_vtk import Probe

import os
from six.moves import range

def stress_strain(out, pb, state, extend=False):
"""
Expand All @@ -49,7 +50,7 @@ def stress_strain(out, pb, state, extend=False):

labels = ['%s -> %s' % (p0, p1) for p0, p1 in zip(ps0, ps1)]
probes = []
for ip in xrange(len(ps0)):
for ip in range(len(ps0)):
p0, p1 = ps0[ip], ps1[ip]
probes.append('line%d' % ip)
probe.add_line_probe('line%d' % ip, p0, p1, n_point)
Expand Down
5 changes: 3 additions & 2 deletions examples/linear_elasticity/its2D_interactive.py
Expand Up @@ -28,6 +28,7 @@
"""
from __future__ import absolute_import
import sys
from six.moves import range
sys.path.append('.')
from optparse import OptionParser

Expand Down Expand Up @@ -65,7 +66,7 @@ def gen_lines(problem):

labels = ['%s -> %s' % (p0, p1) for p0, p1 in zip(ps0, ps1)]
probes = []
for ip in xrange(len(ps0)):
for ip in range(len(ps0)):
p0, p1 = ps0[ip], ps1[ip]
probes.append(LineProbe(p0, p1, n_point))

Expand Down Expand Up @@ -174,7 +175,7 @@ def main():
domain = FEDomain('domain', mesh)

if options.refine > 0:
for ii in xrange(options.refine):
for ii in range(options.refine):
output('refine %d...' % ii)
domain = domain.refine()
output('... %d nodes %d elements'
Expand Down
1 change: 1 addition & 0 deletions examples/linear_elasticity/linear_elastic_probes.py
Expand Up @@ -24,6 +24,7 @@

from sfepy.base.base import Struct
from sfepy.postprocess.probes_vtk import Probe
from six.moves import range

# Define options.
options = {
Expand Down
7 changes: 4 additions & 3 deletions examples/linear_elasticity/modal_analysis.py
Expand Up @@ -43,6 +43,7 @@
from __future__ import absolute_import
import sys
import six
from six.moves import range
sys.path.append('.')
from optparse import OptionParser

Expand Down Expand Up @@ -277,13 +278,13 @@ def main():

vecs = nm.empty((variables.di.ptr[-1], svecs.shape[1]),
dtype=nm.float64)
for ii in xrange(svecs.shape[1]):
for ii in range(svecs.shape[1]):
vecs[:, ii] = variables.make_full_vec(svecs[:, ii])

# Save the eigenvectors.
out = {}
state = pb.create_state()
for ii in xrange(eigs.shape[0]):
for ii in range(eigs.shape[0]):
state.set_full(vecs[:, ii])
aux = state.create_output_dict()
strain = pb.evaluate('ev_cauchy_strain.i.Omega(u)',
Expand All @@ -304,7 +305,7 @@ def main():
scaling = 0.05 * dims.max() / nm.abs(vecs).max()

ds = {}
for ii in xrange(eigs.shape[0]):
for ii in range(eigs.shape[0]):
pd = DomainSpecificPlot('plot_displacements',
['rel_scaling=%s' % scaling,
'color_kind="tensors"',
Expand Down
Expand Up @@ -53,6 +53,7 @@
from argparse import RawDescriptionHelpFormatter, ArgumentParser
import os
import sys
from six.moves import range
sys.path.append('.')

import numpy as nm
Expand Down Expand Up @@ -299,7 +300,7 @@ def main():
label = ', '.join(labels)

log = []
for nx in xrange(*nxs):
for nx in range(*nxs):
shape = (nx, 2)

pb, state, u, gamma2 = solve_problem(shape, dims, young, poisson, force,
Expand Down
1 change: 1 addition & 0 deletions script/convert_mesh.py
Expand Up @@ -11,6 +11,7 @@
"""
from __future__ import absolute_import
import sys
from six.moves import range
sys.path.append('.')

from optparse import OptionParser
Expand Down
1 change: 1 addition & 0 deletions script/eval_ns_forms.py
Expand Up @@ -5,6 +5,7 @@
from __future__ import print_function
from __future__ import absolute_import
import sympy as s
from six.moves import range

def create_scalar(name, n_ep):
vec = s.zeros(n_ep, 1)
Expand Down
1 change: 1 addition & 0 deletions script/extract_surface.py
Expand Up @@ -12,6 +12,7 @@
"""
from __future__ import absolute_import
import sys
from six.moves import range
sys.path.append('.')
from optparse import OptionParser

Expand Down
1 change: 1 addition & 0 deletions script/gen_lobatto1d_c.py
Expand Up @@ -5,6 +5,7 @@
from __future__ import print_function
from __future__ import absolute_import
import sys
from six.moves import range
sys.path.append('.')
import os
from optparse import OptionParser
Expand Down
3 changes: 2 additions & 1 deletion script/save_basis.py
Expand Up @@ -5,6 +5,7 @@
"""
from __future__ import absolute_import
import sys
from six.moves import range
sys.path.append('.')
import os
from optparse import OptionParser
Expand Down Expand Up @@ -50,7 +51,7 @@

def get_dofs(dofs, n_total):
if dofs is None:
dofs = range(n_total)
dofs = list(range(n_total))

else:
dofs = [int(ii) for ii in dofs.split(',')]
Expand Down
3 changes: 2 additions & 1 deletion shaper.py
Expand Up @@ -16,6 +16,7 @@
from sfepy.discrete.problem import Problem
from sfepy.solvers import Solver
import six
from six.moves import range

def solve_stokes(dpb, equations_stokes, nls_conf):
dpb.set_equations(equations_stokes)
Expand Down Expand Up @@ -77,7 +78,7 @@ def solve_navier_stokes(conf, options):
n_step = ts_conf.n_step
step = 0
while 1:
for ii in xrange( n_step ):
for ii in range( n_step ):
output( step )

vec_u = state_dp0('w')
Expand Down

0 comments on commit e241d20

Please sign in to comment.