@@ -113,8 +113,8 @@ def __init__(self, left, right=None, op=None):
113113 Do not use this directly, use `cycler` function instead.
114114 """
115115 self ._keys = _process_keys (left , right )
116- self ._left = copy .copy (left )
117- self ._right = copy .copy (right )
116+ self ._left = copy .deepcopy (left )
117+ self ._right = copy .deepcopy (right )
118118 self ._op = op
119119
120120 @property
@@ -228,11 +228,11 @@ def __iadd__(self, other):
228228 other : Cycler
229229 The second Cycler
230230 """
231- old_self = copy .copy (self )
231+ old_self = copy .deepcopy (self )
232232 self ._keys = _process_keys (old_self , other )
233233 self ._left = old_self
234234 self ._op = zip
235- self ._right = copy .copy (other )
235+ self ._right = copy .deepcopy (other )
236236 return self
237237
238238 def __imul__ (self , other ):
@@ -245,11 +245,11 @@ def __imul__(self, other):
245245 The second Cycler
246246 """
247247
248- old_self = copy .copy (self )
248+ old_self = copy .deepcopy (self )
249249 self ._keys = _process_keys (old_self , other )
250250 self ._left = old_self
251251 self ._op = product
252- self ._right = copy .copy (other )
252+ self ._right = copy .deepcopy (other )
253253 return self
254254
255255 def __eq__ (self , other ):
@@ -334,24 +334,32 @@ def simplify(self):
334334
335335def cycler (* args , ** kwargs ):
336336 """
337- Create a new `Cycler` object from the combination of
338- positional arguments or keyword arguments.
337+ Create a new `Cycler` object from a single positional argument,
338+ a pair of positional arguments, or the combination of keyword arguments.
339339
340340 cycler(arg)
341341 cycler(label1=itr1[, label2=iter2[, ...]])
342342 cycler(label, itr)
343343
344344 Form 1 simply copies a given `Cycler` object.
345+
345346 Form 2 composes a `Cycler` as an inner product of the
346- pairs of keyword arguments.
347+ pairs of keyword arguments. In other words, all of the
348+ iterables are cycled simultaneously, as if through zip().
349+
347350 Form 3 creates a `Cycler` from a label and an iterable.
348- This is useful for when the label cannot be a keyword argument.
351+ This is useful for when the label cannot be a keyword argument
352+ (e.g., an integer or a name that has a space in it).
349353
350354 Parameters
351355 ----------
356+ arg : Cycler
357+ Copy constructor for Cycler.
358+
352359 label : name
353360 The property key. In the 2-arg form of the function,
354- the label can be any hashable object.
361+ the label can be any hashable object. In the keyword argument
362+ form of the function, it must be a valid python identifier.
355363
356364 itr : iterable
357365 Finite length iterable of the property values.
@@ -370,7 +378,7 @@ def cycler(*args, **kwargs):
370378 if not isinstance (args [0 ], Cycler ):
371379 raise TypeError ("If only one positional argument given, it must "
372380 " be a Cycler instance." )
373- return copy .copy (args [0 ])
381+ return copy .deepcopy (args [0 ])
374382 elif len (args ) == 2 :
375383 return _cycler (* args )
376384 elif len (args ) > 2 :
@@ -390,7 +398,7 @@ def _cycler(label, itr):
390398
391399 Parameters
392400 ----------
393- label : str
401+ label : hashable
394402 The property key.
395403
396404 itr : iterable
@@ -408,7 +416,7 @@ def _cycler(label, itr):
408416 raise ValueError (msg )
409417
410418 if label in keys :
411- return copy .copy (itr )
419+ return copy .deepcopy (itr )
412420 else :
413421 lab = keys .pop ()
414422 itr = list (v [lab ] for v in itr )
0 commit comments