40
40
{'color': 'b', 'linestyle': '-.'}
41
41
"""
42
42
43
- from __future__ import (absolute_import , division , print_function ,
44
- unicode_literals )
45
43
46
44
import copy
47
45
from functools import reduce
@@ -107,7 +105,7 @@ def concat(left, right):
107
105
return reduce (add , (_cycler (k , _l [k ] + _r [k ]) for k in left .keys ))
108
106
109
107
110
- class Cycler ( object ) :
108
+ class Cycler :
111
109
"""
112
110
Composable cycles.
113
111
@@ -231,7 +229,7 @@ def _from_iter(cls, label, itr):
231
229
"""
232
230
ret = cls (None )
233
231
ret ._left = list ({label : v } for v in itr )
234
- ret ._keys = set ([ label ])
232
+ ret ._keys = { label }
235
233
return ret
236
234
237
235
def __getitem__ (self , key ):
@@ -263,7 +261,7 @@ def __add__(self, other):
263
261
"""
264
262
if len (self ) != len (other ):
265
263
raise ValueError ("Can only add equal length cycles, "
266
- "not {0 } and {1 }" .format (len (self ), len (other )))
264
+ "not {} and {}" .format (len (self ), len (other )))
267
265
return Cycler (self , other , zip )
268
266
269
267
def __mul__ (self , other ):
@@ -347,7 +345,7 @@ def __repr__(self):
347
345
if self ._right is None :
348
346
lab = self .keys .pop ()
349
347
itr = list (v [lab ] for v in self )
350
- return "cycler({lab!r}, {itr!r})" . format ( lab = lab , itr = itr )
348
+ return f "cycler({ lab !r} , { itr !r} )"
351
349
else :
352
350
op = op_map .get (self ._op , '?' )
353
351
msg = "({left!r} {op} {right!r})"
@@ -358,11 +356,11 @@ def _repr_html_(self):
358
356
output = "<table>"
359
357
sorted_keys = sorted (self .keys , key = repr )
360
358
for key in sorted_keys :
361
- output += "<th>{key!r}</th>" . format ( key = key )
359
+ output += f "<th>{ key !r} </th>"
362
360
for d in iter (self ):
363
361
output += "<tr>"
364
362
for k in sorted_keys :
365
- output += "<td>{val !r}</td>" . format ( val = d [ k ])
363
+ output += f "<td>{ d [ k ] !r} </td>"
366
364
output += "</tr>"
367
365
output += "</table>"
368
366
return output
0 commit comments