Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ htmlcov/
cover/
.coverage
.cache
.pytest_cache
nosetests.xml
coverage.xml
cover/
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ matrix:

install:
- python setup.py install
- pip install pytest pytest-cov coverage six
- pip install pytest pytest-cov coverage

script:
- coverage run run_tests.py
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ install:
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""

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

# Install the generated wheel package to test it
- "python setup.py install"
Expand Down
2 changes: 0 additions & 2 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ requirements:
build:
- python
- setuptools
- six

run:
- python
- six

test:
# Python imports
Expand Down
20 changes: 10 additions & 10 deletions cycler.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six
import copy
from functools import reduce
from itertools import product, cycle
from six.moves import zip, reduce
from operator import mul, add
import copy
import sys

if sys.version_info < (3,):
from itertools import izip as zip

__version__ = '0.10.0'

Expand Down Expand Up @@ -183,7 +186,6 @@ def change_key(self, old, new):
def _compose(self):
"""
Compose the 'left' and 'right' components of this cycle
with the proper operation (zip or product as of now)
"""
for a, b in self._op(self._left, self._right):
out = dict()
Expand Down Expand Up @@ -220,8 +222,7 @@ def __getitem__(self, key):
# TODO : maybe add numpy style fancy slicing
if isinstance(key, slice):
trans = self.by_key()
return reduce(add, (_cycler(k, v[key])
for k, v in six.iteritems(trans)))
return reduce(add, (_cycler(k, v[key]) for k, v in trans.items()))
else:
raise ValueError("Can only use slices with Cycler.__getitem__")

Expand Down Expand Up @@ -259,8 +260,7 @@ def __mul__(self, other):
return Cycler(self, other, product)
elif isinstance(other, int):
trans = self.by_key()
return reduce(add, (_cycler(k, v*other)
for k, v in six.iteritems(trans)))
return reduce(add, (_cycler(k, v*other) for k, v in trans.items()))
else:
return NotImplemented

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

trans = self.by_key()
return reduce(add, (_cycler(k, v) for k, v in six.iteritems(trans)))
return reduce(add, (_cycler(k, v) for k, v in trans.items()))

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

if kwargs:
return reduce(add, (_cycler(k, v) for k, v in six.iteritems(kwargs)))
return reduce(add, (_cycler(k, v) for k, v in kwargs.items()))

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

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
description='Composable style cycles',
url='https://github.com/matplotlib/cycler',
platforms='Cross platform (Linux, Mac OSX, Windows)',
install_requires=['six'],
license="BSD",
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
classifiers=['Development Status :: 4 - Beta',
Expand Down
20 changes: 13 additions & 7 deletions test_cycler.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
from __future__ import (absolute_import, division, print_function)

import six
from six.moves import zip, range
from cycler import cycler, Cycler, concat
import pytest
from itertools import product, cycle, chain
from operator import add, iadd, mul, imul
from collections import defaultdict
from operator import add, iadd, mul, imul
from itertools import product, cycle, chain
import sys

import pytest

from cycler import cycler, Cycler, concat

if sys.version_info < (3,):
from itertools import izip as zip
range = xrange
str = unicode


def _cycler_helper(c, length, keys, values):
Expand Down Expand Up @@ -147,7 +153,7 @@ def test_fail_getime():
def _repr_tester_helper(rpr_func, cyc, target_repr):
test_repr = getattr(cyc, rpr_func)()

assert six.text_type(test_repr) == six.text_type(target_repr)
assert str(test_repr) == str(target_repr)


def test_repr():
Expand Down