@@ -216,7 +216,7 @@ def _from_iter(cls, label, itr):
216216 def __getitem__ (self , key ):
217217 # TODO : maybe add numpy style fancy slicing
218218 if isinstance (key , slice ):
219- trans = self ._transpose ()
219+ trans = self .by_key ()
220220 return reduce (add , (_cycler (k , v [key ])
221221 for k , v in six .iteritems (trans )))
222222 else :
@@ -255,7 +255,7 @@ def __mul__(self, other):
255255 if isinstance (other , Cycler ):
256256 return Cycler (self , other , product )
257257 elif isinstance (other , int ):
258- trans = self ._transpose ()
258+ trans = self .by_key ()
259259 return reduce (add , (_cycler (k , v * other )
260260 for k , v in six .iteritems (trans )))
261261 else :
@@ -346,17 +346,21 @@ def _repr_html_(self):
346346 output += "</table>"
347347 return output
348348
349- def _transpose (self ):
350- """
351- Internal helper function which iterates through the
352- styles and returns a dict of lists instead of a list of
353- dicts. This is needed for multiplying by integers and
354- for __getitem__
349+ def by_key (self ):
350+ """Values by key
351+
352+ This returns the transposed values of the cycler. Iterating
353+ over a `Cycler` yields dicts with a single value for each key,
354+ this method returns a `dict` of `list` which are the values
355+ for the given key.
356+
357+ The returned value can be used to create an equivalent `Cycler`
358+ using only `+`.
355359
356360 Returns
357361 -------
358- trans : dict
359- dict of lists for the styles
362+ transpose : dict
363+ dict of lists of the values for each key.
360364 """
361365
362366 # TODO : sort out if this is a bottle neck, if there is a better way
@@ -386,7 +390,7 @@ def simplify(self):
386390 # ((a + b) + (c + d))
387391 # I would believe that there is some performance implications
388392
389- trans = self ._transpose ()
393+ trans = self .by_key ()
390394 return reduce (add , (_cycler (k , v ) for k , v in six .iteritems (trans )))
391395
392396 def concat (self , other ):
@@ -453,8 +457,8 @@ def concat(left, right):
453457
454458 raise ValueError (msg )
455459
456- _l = left ._transpose ()
457- _r = right ._transpose ()
460+ _l = left .by_key ()
461+ _r = right .by_key ()
458462 return reduce (add , (_cycler (k , _l [k ] + _r [k ]) for k in left .keys ))
459463
460464
0 commit comments