Use enumerate(x) instead of zip(range(x), x)
authorLars-Peter Clausen <lars@metafoo.de>
Thu, 2 Feb 2012 20:12:37 +0000 (21:12 +0100)
committerLars-Peter Clausen <lars@metafoo.de>
Thu, 2 Feb 2012 20:28:00 +0000 (21:28 +0100)
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
migen/actorlib/control.py
migen/corelogic/fsm.py
migen/flow/plumbing.py

index 9819c5dfebd591959ec59b5e9a90ff9f780bf2f2..dffcb47daf6106d96e888b922195f02d2a7b4a9b 100644 (file)
@@ -17,9 +17,9 @@ class For(Actor):
                if step: params.append("step")
                self.d_bv = [BV(bits_for(dimension)) for dimension in maxima]
                l_sink = [("d{0}".format(n), [(p, bv) for p in params])
-                       for n, bv in zip(range(len(self.d_bv)), self.d_bv)]
+                       for n, bv in enumerate(self.d_bv)]
                l_source = [("d{0}".format(n), bv)
-                       for n, bv in zip(range(len(self.d_bv)), self.d_bv)]
+                       for n, bv in enumerate(self.d_bv)]
                Actor.__init__(self, SchedulingModel(SchedulingModel.DYNAMIC),
                        ("sink", Sink, l_sink),
                        ("source", Source, l_source))
index a3d3ccb67a1faaea406e8e80b9ef9fc37392ab53..d2d1848171d7079cf75e6b11fed7514eccf331f8 100644 (file)
@@ -5,7 +5,7 @@ class FSM:
                self._state_bv = BV(bits_for(len(states)-1))
                self._state = Signal(self._state_bv)
                self._next_state = Signal(self._state_bv)
-               for state, n in zip(states, range(len(states))):
+               for n, state in enumerate(states):
                        setattr(self, state, Constant(n, self._state_bv))
                self.actions = [[] for i in range(len(states))]
        
@@ -20,7 +20,7 @@ class FSM:
        
        def get_fragment(self):
                cases = [[Constant(s, self._state_bv)] + a
-                       for s, a in zip(range(len(self.actions)), self.actions) if a]
+                       for s, a in enumerate(self.actions) if a]
                comb = [
                        self._next_state.eq(self._state),
                        Case(self._state, *cases)
index e9d2454d991dd44cc3d1e617047240e24522d6db..398b3da9e8d8401cabd26fd7be400f00819ca341 100644 (file)
@@ -19,8 +19,8 @@ class Combinator(Actor):
        def __init__(self, layout, *subrecords):
                source = Record(layout)
                subrecords = [source.subrecord(*subr) for subr in subrecords]
-               eps = [("sink{0}".format(x[0]), Sink, x[1])
-                       for x in zip(range(len(subrecords)), subrecords)]
+               eps = [("sink{0}".format(n), Sink, r)
+                       for x in enumerate(subrecords)]
                ep_source = ("source", Source, source)
                eps.append(ep_source)
                Actor.__init__(self,
@@ -39,8 +39,8 @@ class Splitter(Actor):
        def __init__(self, layout, *subrecords):
                sink = Record(layout)
                subrecords = [sink.subrecord(*subr) for subr in subrecords]
-               eps = [("source{0}".format(x[0]), Source, x[1])
-                       for x in zip(range(len(subrecords)), subrecords)]
+               eps = [("source{0}".format(n), Source, r)
+                       for n, r in enumerate(subrecords)]
                ep_sink = ("sink", Sink, sink)
                eps.append(ep_sink)
                Actor.__init__(self,