Commit f52af23b authored by Tjerk Vreeken's avatar Tjerk Vreeken

Python 2to3 fixes: xrange() to range()

parent 1c68af1a
......@@ -154,7 +154,7 @@ class ControlTreeMixin(OptimizationProblem):
branch(current_branch + str(i))
current_branch = ''
branches[current_branch] = range(self.ensemble_size)
branches[current_branch] = list(range(self.ensemble_size))
branch(current_branch)
logger.debug("ControlTreeMixin: Control tree is:")
......@@ -176,7 +176,7 @@ class ControlTreeMixin(OptimizationProblem):
nnz = np.count_nonzero(els)
for member in members:
self._control_indices[control_input][
member, els] = range(count, count + nnz)
member, els] = list(range(count, count + nnz))
count += nnz
# Construct bounds and initial guess
......
......@@ -293,7 +293,7 @@ class TestModelicaMixin(TestCase):
integral = self.problem.integral('x', 0.05, 0.95)
knots = self.problem.times()[1:-1]
verify = MX(0.0)
for i in xrange(len(knots) - 1):
for i in range(len(knots) - 1):
verify += 0.5 * (self.problem.state_at('x', knots[i]) + self.problem.state_at(
'x', knots[i + 1])) * (knots[i + 1] - knots[i])
self.assertEqual(repr(integral), repr(verify))
......@@ -304,7 +304,7 @@ class TestModelicaMixin(TestCase):
knots.extend(self.problem.times()[2:-1])
knots.append(0.951)
verify = MX(0.0)
for i in xrange(len(knots) - 1):
for i in range(len(knots) - 1):
verify += 0.5 * (self.problem.state_at('x', knots[i]) + self.problem.state_at(
'x', knots[i + 1])) * (knots[i + 1] - knots[i])
self.assertEqual(repr(integral), repr(verify))
......@@ -312,7 +312,7 @@ class TestModelicaMixin(TestCase):
integral = self.problem.integral('x', 0.0, 0.951)
knots = list(self.problem.times()[0:-1]) + [0.951]
verify = MX(0.0)
for i in xrange(len(knots) - 1):
for i in range(len(knots) - 1):
verify += 0.5 * (self.problem.state_at('x', knots[i]) + self.problem.state_at(
'x', knots[i + 1])) * (knots[i + 1] - knots[i])
self.assertEqual(repr(integral), repr(verify))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment