Skip to content

Commit 75b0d0f

Browse files
authored
Merge pull request #68 from AliMuhammadOfficial/master
Improved some formatting
2 parents ff11e56 + e98960a commit 75b0d0f

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

cycler.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,13 @@ def change_key(self, old, new):
185185
if old == new:
186186
return
187187
if new in self._keys:
188-
raise ValueError("Can't replace %s with %s, %s is already a key" %
189-
(old, new, new))
188+
raise ValueError(
189+
"Can't replace {old} with {new}, {new} is already a key"
190+
.format(old=old, new=new)
191+
)
190192
if old not in self._keys:
191-
raise KeyError("Can't replace %s with %s, %s is not a key" %
192-
(old, new, old))
193+
raise KeyError("Can't replace {old} with {new}, {old} is not a key"
194+
.format(old=old, new=new))
193195

194196
self._keys.remove(old)
195197
self._keys.add(new)
@@ -246,7 +248,7 @@ def __iter__(self):
246248
yield dict(left)
247249
else:
248250
for a, b in self._op(self._left, self._right):
249-
out = dict()
251+
out = {}
250252
out.update(a)
251253
out.update(b)
252254
yield out

test_cycler.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ def test_add():
4343
c1 = cycler(c='rgb')
4444
c2 = cycler(lw=range(3))
4545
# addition
46-
_cycler_helper(c1+c2, 3, ['c', 'lw'], [list('rgb'), range(3)])
47-
_cycler_helper(c2+c1, 3, ['c', 'lw'], [list('rgb'), range(3)])
48-
_cycles_equal(c2+c1, c1+c2)
46+
_cycler_helper(c1 + c2, 3, ['c', 'lw'], [list('rgb'), range(3)])
47+
_cycler_helper(c2 + c1, 3, ['c', 'lw'], [list('rgb'), range(3)])
48+
_cycles_equal(c2 + c1, c1 + c2)
4949

5050

5151
def test_add_len_mismatch():
@@ -89,12 +89,12 @@ def test_inplace():
8989
def test_constructor():
9090
c1 = cycler(c='rgb')
9191
c2 = cycler(ec=c1)
92-
_cycler_helper(c1+c2, 3, ['c', 'ec'], [['r', 'g', 'b']]*2)
92+
_cycler_helper(c1 + c2, 3, ['c', 'ec'], [['r', 'g', 'b']] * 2)
9393
c3 = cycler(c=c1)
94-
_cycler_helper(c3+c2, 3, ['c', 'ec'], [['r', 'g', 'b']]*2)
94+
_cycler_helper(c3 + c2, 3, ['c', 'ec'], [['r', 'g', 'b']] * 2)
9595
# Using a non-string hashable
9696
c4 = cycler(1, range(3))
97-
_cycler_helper(c4+c1, 3, [1, 'c'], [range(3), ['r', 'g', 'b']])
97+
_cycler_helper(c4 + c1, 3, [1, 'c'], [range(3), ['r', 'g', 'b']])
9898

9999
# addition using cycler()
100100
_cycler_helper(cycler(c='rgb', lw=range(3)),
@@ -118,7 +118,7 @@ def test_failures():
118118

119119
c3 = cycler(ec=c1)
120120

121-
pytest.raises(ValueError, cycler, c=c2+c3)
121+
pytest.raises(ValueError, cycler, c=c2 + c3)
122122

123123

124124
def test_simplify():
@@ -130,12 +130,12 @@ def test_simplify():
130130

131131
def test_multiply():
132132
c1 = cycler(c='rgb')
133-
_cycler_helper(2*c1, 6, ['c'], ['rgb'*2])
133+
_cycler_helper(2 * c1, 6, ['c'], ['rgb' * 2])
134134

135135
c2 = cycler(ec=c1)
136136
c3 = c1 * c2
137137

138-
_cycles_equal(2*c3, c3*2)
138+
_cycles_equal(2 * c3, c3 * 2)
139139

140140

141141
def test_mul_fails():
@@ -208,7 +208,7 @@ def test_call():
208208
c_cycle = c()
209209
assert isinstance(c_cycle, cycle)
210210
j = 0
211-
for a, b in zip(2*c, c_cycle):
211+
for a, b in zip(2 * c, c_cycle):
212212
j += 1
213213
assert a == b
214214

@@ -373,7 +373,7 @@ def test_contains():
373373
assert 'a' not in b
374374
assert 'b' not in a
375375

376-
ab = a+b
376+
ab = a + b
377377

378378
assert 'a' in ab
379379
assert 'b' in ab

0 commit comments

Comments
 (0)