4040 {'color': 'b', 'linestyle': '-.'}
4141"""
4242
43- from __future__ import (absolute_import , division , print_function ,
44- unicode_literals )
4543
4644import copy
4745from functools import reduce
4846from itertools import product , cycle
4947from operator import mul , add
50- import sys
51-
52- if sys .version_info < (3 ,):
53- from itertools import izip as zip
5448
5549__version__ = '0.10.0'
5650
@@ -107,7 +101,7 @@ def concat(left, right):
107101 return reduce (add , (_cycler (k , _l [k ] + _r [k ]) for k in left .keys ))
108102
109103
110- class Cycler ( object ) :
104+ class Cycler :
111105 """
112106 Composable cycles.
113107
@@ -231,7 +225,7 @@ def _from_iter(cls, label, itr):
231225 """
232226 ret = cls (None )
233227 ret ._left = list ({label : v } for v in itr )
234- ret ._keys = set ([ label ])
228+ ret ._keys = { label }
235229 return ret
236230
237231 def __getitem__ (self , key ):
@@ -263,7 +257,7 @@ def __add__(self, other):
263257 """
264258 if len (self ) != len (other ):
265259 raise ValueError ("Can only add equal length cycles, "
266- "not {0 } and {1}" . format ( len (self ), len ( other )) )
260+ f "not { len ( self ) } and { len (other )} " )
267261 return Cycler (self , other , zip )
268262
269263 def __mul__ (self , other ):
@@ -347,7 +341,7 @@ def __repr__(self):
347341 if self ._right is None :
348342 lab = self .keys .pop ()
349343 itr = list (v [lab ] for v in self )
350- return "cycler({lab!r}, {itr!r})" . format ( lab = lab , itr = itr )
344+ return f "cycler({ lab !r} , { itr !r} )"
351345 else :
352346 op = op_map .get (self ._op , '?' )
353347 msg = "({left!r} {op} {right!r})"
@@ -358,11 +352,11 @@ def _repr_html_(self):
358352 output = "<table>"
359353 sorted_keys = sorted (self .keys , key = repr )
360354 for key in sorted_keys :
361- output += "<th>{key!r}</th>" . format ( key = key )
355+ output += f "<th>{ key !r} </th>"
362356 for d in iter (self ):
363357 output += "<tr>"
364358 for k in sorted_keys :
365- output += "<td>{val !r}</td>" . format ( val = d [ k ])
359+ output += f "<td>{ d [ k ] !r} </td>"
366360 output += "</tr>"
367361 output += "</table>"
368362 return output
0 commit comments