|
43 | 43 | from __future__ import (absolute_import, division, print_function,
|
44 | 44 | unicode_literals)
|
45 | 45 |
|
46 |
| -import six |
| 46 | +import copy |
| 47 | +from functools import reduce |
47 | 48 | from itertools import product, cycle
|
48 |
| -from six.moves import zip, reduce |
49 | 49 | from operator import mul, add
|
50 |
| -import copy |
| 50 | +import sys |
| 51 | + |
| 52 | +if sys.version_info < (3,): |
| 53 | + from itertools import izip as zip |
51 | 54 |
|
52 | 55 | __version__ = '0.10.0'
|
53 | 56 |
|
@@ -183,7 +186,6 @@ def change_key(self, old, new):
|
183 | 186 | def _compose(self):
|
184 | 187 | """
|
185 | 188 | Compose the 'left' and 'right' components of this cycle
|
186 |
| - with the proper operation (zip or product as of now) |
187 | 189 | """
|
188 | 190 | for a, b in self._op(self._left, self._right):
|
189 | 191 | out = dict()
|
@@ -220,8 +222,7 @@ def __getitem__(self, key):
|
220 | 222 | # TODO : maybe add numpy style fancy slicing
|
221 | 223 | if isinstance(key, slice):
|
222 | 224 | trans = self.by_key()
|
223 |
| - return reduce(add, (_cycler(k, v[key]) |
224 |
| - for k, v in six.iteritems(trans))) |
| 225 | + return reduce(add, (_cycler(k, v[key]) for k, v in trans.items())) |
225 | 226 | else:
|
226 | 227 | raise ValueError("Can only use slices with Cycler.__getitem__")
|
227 | 228 |
|
@@ -259,8 +260,7 @@ def __mul__(self, other):
|
259 | 260 | return Cycler(self, other, product)
|
260 | 261 | elif isinstance(other, int):
|
261 | 262 | trans = self.by_key()
|
262 |
| - return reduce(add, (_cycler(k, v*other) |
263 |
| - for k, v in six.iteritems(trans))) |
| 263 | + return reduce(add, (_cycler(k, v*other) for k, v in trans.items())) |
264 | 264 | else:
|
265 | 265 | return NotImplemented
|
266 | 266 |
|
@@ -396,7 +396,7 @@ def simplify(self):
|
396 | 396 | # I would believe that there is some performance implications
|
397 | 397 |
|
398 | 398 | trans = self.by_key()
|
399 |
| - return reduce(add, (_cycler(k, v) for k, v in six.iteritems(trans))) |
| 399 | + return reduce(add, (_cycler(k, v) for k, v in trans.items())) |
400 | 400 |
|
401 | 401 | def concat(self, other):
|
402 | 402 | """Concatenate this cycler and an other.
|
@@ -523,7 +523,7 @@ def cycler(*args, **kwargs):
|
523 | 523 | "positional argument. Use keyword arguments instead.")
|
524 | 524 |
|
525 | 525 | if kwargs:
|
526 |
| - return reduce(add, (_cycler(k, v) for k, v in six.iteritems(kwargs))) |
| 526 | + return reduce(add, (_cycler(k, v) for k, v in kwargs.items())) |
527 | 527 |
|
528 | 528 | raise TypeError("Must have at least a positional OR keyword arguments")
|
529 | 529 |
|
|
0 commit comments