Skip to content

Commit 5fce18a

Browse files
committed
Remove dependency on six.
Mostly so that Matplotlib doesn't depend *transitively* on six either :) - six.iteritems() -> dict.items(): OK even on Py2, we directly consume the iterator/list with reduce anyways, and I doubt that the perfomance change is measurable. - six.moves.zip() could have been replaced with builtin zip() on both Py2 and Py3 because we always exhaust the iterator immediately anyways, but it also acts as a lookup key in `Cycler.__len__` so I decided to just play it safe and have a conditional import (on Py2, six.moves.zip is an alias for itertools.zip). Also added new .pytest_cache directory to gitignore.
1 parent ffa3377 commit 5fce18a

File tree

7 files changed

+26
-22
lines changed

7 files changed

+26
-22
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ htmlcov/
3333
cover/
3434
.coverage
3535
.cache
36+
.pytest_cache
3637
nosetests.xml
3738
coverage.xml
3839
cover/

Diff for: .travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ matrix:
1313

1414
install:
1515
- python setup.py install
16-
- pip install pytest pytest-cov coverage six
16+
- pip install pytest pytest-cov coverage
1717

1818
script:
1919
- coverage run run_tests.py

Diff for: appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ install:
2020
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""
2121

2222
# Install the build and runtime dependencies of the project.
23-
- "pip install -v six nose pytest pytest-cov coverage"
23+
- "pip install -v nose pytest pytest-cov coverage"
2424

2525
# Install the generated wheel package to test it
2626
- "python setup.py install"

Diff for: conda-recipe/meta.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ requirements:
3030
build:
3131
- python
3232
- setuptools
33-
- six
3433

3534
run:
3635
- python
37-
- six
3836

3937
test:
4038
# Python imports

Diff for: cycler.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@
4343
from __future__ import (absolute_import, division, print_function,
4444
unicode_literals)
4545

46-
import six
46+
import copy
47+
from functools import reduce
4748
from itertools import product, cycle
48-
from six.moves import zip, reduce
4949
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
5154

5255
__version__ = '0.10.0'
5356

@@ -183,7 +186,6 @@ def change_key(self, old, new):
183186
def _compose(self):
184187
"""
185188
Compose the 'left' and 'right' components of this cycle
186-
with the proper operation (zip or product as of now)
187189
"""
188190
for a, b in self._op(self._left, self._right):
189191
out = dict()
@@ -220,8 +222,7 @@ def __getitem__(self, key):
220222
# TODO : maybe add numpy style fancy slicing
221223
if isinstance(key, slice):
222224
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()))
225226
else:
226227
raise ValueError("Can only use slices with Cycler.__getitem__")
227228

@@ -259,8 +260,7 @@ def __mul__(self, other):
259260
return Cycler(self, other, product)
260261
elif isinstance(other, int):
261262
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()))
264264
else:
265265
return NotImplemented
266266

@@ -396,7 +396,7 @@ def simplify(self):
396396
# I would believe that there is some performance implications
397397

398398
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()))
400400

401401
def concat(self, other):
402402
"""Concatenate this cycler and an other.
@@ -523,7 +523,7 @@ def cycler(*args, **kwargs):
523523
"positional argument. Use keyword arguments instead.")
524524

525525
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()))
527527

528528
raise TypeError("Must have at least a positional OR keyword arguments")
529529

Diff for: setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
description='Composable style cycles',
99
url='https://github.com/matplotlib/cycler',
1010
platforms='Cross platform (Linux, Mac OSX, Windows)',
11-
install_requires=['six'],
1211
license="BSD",
1312
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
1413
classifiers=['Development Status :: 4 - Beta',

Diff for: test_cycler.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
from __future__ import (absolute_import, division, print_function)
22

3-
import six
4-
from six.moves import zip, range
5-
from cycler import cycler, Cycler, concat
6-
import pytest
7-
from itertools import product, cycle, chain
8-
from operator import add, iadd, mul, imul
93
from collections import defaultdict
4+
from operator import add, iadd, mul, imul
5+
from itertools import product, cycle, chain
6+
import sys
7+
8+
import pytest
9+
10+
from cycler import cycler, Cycler, concat
11+
12+
if sys.version_info < (3,):
13+
from itertools import izip as zip
14+
range = xrange
15+
str = unicode
1016

1117

1218
def _cycler_helper(c, length, keys, values):
@@ -147,7 +153,7 @@ def test_fail_getime():
147153
def _repr_tester_helper(rpr_func, cyc, target_repr):
148154
test_repr = getattr(cyc, rpr_func)()
149155

150-
assert six.text_type(test_repr) == six.text_type(target_repr)
156+
assert str(test_repr) == str(target_repr)
151157

152158

153159
def test_repr():

0 commit comments

Comments
 (0)