+
     h8  c                   sn    R t ^ RIt^ RIHt ^ RIHtHt ^ RIHtH	t	 Rt
R tR t ! R R	4      tR
 tR tR# )a  
Cycler
======

Cycling through combinations of values, producing dictionaries.

You can add cyclers::

    from cycler import cycler
    cc = (cycler(color=list('rgb')) +
          cycler(linestyle=['-', '--', '-.']))
    for d in cc:
        print(d)

Results in::

    {'color': 'r', 'linestyle': '-'}
    {'color': 'g', 'linestyle': '--'}
    {'color': 'b', 'linestyle': '-.'}


You can multiply cyclers::

    from cycler import cycler
    cc = (cycler(color=list('rgb')) *
          cycler(linestyle=['-', '--', '-.']))
    for d in cc:
        print(d)

Results in::

    {'color': 'r', 'linestyle': '-'}
    {'color': 'r', 'linestyle': '--'}
    {'color': 'r', 'linestyle': '-.'}
    {'color': 'g', 'linestyle': '-'}
    {'color': 'g', 'linestyle': '--'}
    {'color': 'g', 'linestyle': '-.'}
    {'color': 'b', 'linestyle': '-'}
    {'color': 'b', 'linestyle': '--'}
    {'color': 'b', 'linestyle': '-.'}
N)reduce)productcycle)muladdz0.10.0c                s   V e   \        \        V 4      4      M/ pVe   \        \        V4      4      M/ p\        VP                  4       4      p\        VP                  4       4      pWE,          '       d   \	        R4      hWE,          # )z
Helper function to compose cycler keys.

Parameters
----------
left, right : iterable of dictionaries or None
    The cyclers to be composed.

Returns
-------
keys : set
    The keys in the composition of the two cyclers.
z"Can not compose overlapping cycles)Znextitersetkeys
ValueError)leftrightZl_peekZr_peekZl_keyZr_keys   &&    +/usr/lib/python3.14/site-packages/cycler.py_process_keysr   4   si     "&!1T$t*rF"'"3T$u+FEE}}=>>=    c                sj  aa V P                   VP                   8w  dS   \        RP                  V P                   VP                   ,          V P                   VP                   ,          R7      4      hV P                  4       oVP                  4       o\	        \
        VV3R lV P                    4       4      # )a  
Concatenate `Cycler`\s, as if chained using `itertools.chain`.

The keys must match exactly.

Examples
--------
>>> num = cycler('a', range(3))
>>> let = cycler('a', 'abc')
>>> num.concat(let)
cycler('a', [0, 1, 2, 'a', 'b', 'c'])

Returns
-------
`Cycler`
    The concatenated cycler.
zBKeys do not match:
	Intersection: {both!r}
	Disjoint: {just_one!r})ZbothZjust_onec              3   sf   <"   T F&  p\        VSV,          SV,          ,           4      x  K(  	  R # 5iN_cycler).0k_l_rs   & r   	<genexpr>Zconcat.<locals>.<genexpr>e   s'     E9a2a52a5=119s   .1)r   r   formatby_keyr    r   )r	   r
   r   r   s   &&@@r   concatr   K   s    $ yyEJJ 44:F"&))ejj"8&*ii%**&< 5; 5>? 	?
 
B	B#E499EFFr   c                   s   a  ] tR t^ht o RtR tRR ltR t]R 4       t	R t
]R 4       tR	 tR
 tR tR tR tR tR tR tR tR tRtR tR tR t]tR t]tRtV tR# )Cyclera  
Composable cycles.

This class has compositions methods:

``+``
  for 'inner' products (zip)

``+=``
  in-place ``+``

``*``
  for outer products (`itertools.product`) and integer multiplication

``*=``
  in-place ``*``

and supports basic slicing via ``[]``.

Parameters
----------
left, right : Cycler or None
    The 'left' and 'right' cyclers.
op : func or None
    Function which composes the 'left' and 'right' cyclers.
c                s    \        V 4      # r   )r   self   &r   __call__ZCycler.__call__   s    T{r   Nc                sh   \        V\        4      '       d2   \        VP                  VP                  VP                  4      V n        M7Ve-   V Uu. uF  p\
        P
                  ! V4      NK  	  upV n        MRV n        \        V\        4      '       d2   \        VP                  VP                  VP                  4      V n        M7Ve-   V Uu. uF  p\
        P
                  ! V4      NK  	  upV n        MRV n        \        V P                  V P                  4      V n        W0n        R# u upi u upi )zN
Semi-private init.

Do not use this directly, use `cycler` function instead.
N)
isinstancer   _left_right_opcopyr   _keys)r   r	   r
   opvs   &&&& r   __init__ZCycler.__init__   s     dF##

DKKBDJ 1551$))A,5DJDJeV$$ ellEIIFDK 277A499Q<7DKDK"4::t{{;
 6 8s   D*D/c                s    WP                   9   # r   )r#   )r   r      &&r   __contains__ZCycler.__contains__   s    JJr   c                s,    \        V P                  4      # )z!The keys this Cycler knows about.)r   r#   r   r   r   r   ZCycler.keys   s     4::r   c                s   W8X  d   R# W P                   9   d   \        RP                  WR7      4      hWP                   9  d   \        RP                  WR7      4      hV P                   P	                  V4       V P                   P                  V4       V P                  e8   WP                  P                  9   d   V P                  P                  W4       R# \        V P                  \        4      '       d   V P                  P                  W4       R# V P                   Uu. uF  q2W1,          /NK  	  upV n
        R# u upi )z
Change a key in this cycler to a new name.
Modification is performed in-place.

Does nothing if the old key is the same as the new key.
Raises a ValueError if the new key is already a key.
Raises a KeyError if the old key isn't a key.
Nz6Can't replace {old} with {new}, {new} is already a key)oldnewz2Can't replace {old} with {new}, {old} is not a key)r#   r   r   ZKeyErrorZremover   r    r   
change_keyr   r   r   )r   r)   r*   Zentrys   &&& r   r+   ZCycler.change_key   s     :**HC)  jj O"FsF46 6 	

#

s;;"skk.>.>'>KK""3, 

F++JJ!!#+
 :>D
+DDJDs   %Ec                s\   a V ! R4      p\        V3R lV 4       4      Vn        S0Vn        V# )a5  
Class method to create 'base' Cycler objects
that do not have a 'right' or 'op' and for which
the 'left' object is not another Cycler.

Parameters
----------
label : str
    The property key.

itr : iterable
    Finite length iterable of the property values.

Returns
-------
`Cycler`
    New 'base' cycler.
Nc              3   s,   <"   T F	  pSV/x  K  	  R # 5ir    )r   r%   label   & r   r   Z$Cycler._from_iter.<locals>.<genexpr>   s     1S%Ss   )listr   r#   )Zclsr-   itrZrets   &f& r   
_from_iterZCycler._from_iter   s.    ( $i1S11	G	
r   c                s   a \        S\        4      '       d9   V P                  4       p\        \        V3R  lVP                  4        4       4      # \        R4      h)c              3   sL   <"   T F  w  r\        WS,          4      x  K  	  R # 5ir   r   )r   r   r%   key   &  r   r   Z%Cycler.__getitem__.<locals>.<genexpr>   s     M}tqS6 2 2}   !$z+Can only use slices with Cycler.__getitem__)r   Zslicer   r    r   itemsr   )r   r2   trans   &f r   __getitem__ZCycler.__getitem__   s@    c5!!KKME#Mu{{}MNNJKKr   c              #  s  "   V P                   f#   V P                   F  p\        V4      x  K  	  R # V P                  V P                  V P                   4       F-  w  r#/ pVP	                  V4       VP	                  V4       Vx  K/  	  R # 5ir   )r    r   Zdictr!   Zupdate)r   r	   about   &    r   __iter__ZCycler.__iter__   sh     ;;

4j  # T[[9

1

1		 :s   B
Bc                s    \        V 4      \        V4      8w  d$   \        R\        V 4       R\        V4       24      h\        W\        4      # )zY
Pair-wise combine two equal length cyclers (zip).

Parameters
----------
other : Cycler
z&Can only add equal length cycles, not z and )lenr   r   zipr   otherr'   r   __add__ZCycler.__add__   sN     t9E
" $$'I;eCJ<A B Bd3''r   c                s   a \        S\        4      '       d   \        V S\        4      # \        S\        4      '       d9   V P	                  4       p\        \        V3R lVP                  4        4       4      # \        # )z|
Outer product of two cyclers (`itertools.product`) or integer
multiplication.

Parameters
----------
other : Cycler or int
c              3   sL   <"   T F  w  r\        WS,          4      x  K  	  R # 5ir   r   )r   r   r%   rA   r3   r   r   Z!Cycler.__mul__.<locals>.<genexpr>  s     NU7 3 3r4   )	r   r   r   Zintr   r    r   r5   ZNotImplemented)r   rA   r6   r7   r   __mul__ZCycler.__mul__  sX     eV$$$w//s##KKME#NNOO!!r   c                s    W,          # r   r,   r@   r'   r   __rmul__ZCycler.__rmul__  s
    |r   c                s    \         \        \        \        /pV P                  f   \        V P                  4      # \        V P                  4      p\        V P                  4      pWP                  ,          ! W#4      # r   )r?   Zminr   r   r    r>   r   r!   )r   Zop_dictZl_lenZr_lens   &   r   __len__ZCycler.__len__  sU    Wc*;;tzz?"DJJDKK xx ..r   c                   \        V\        4      '       g   \        R4      h\        P                  ! V 4      p\	        W!4      V n        W n        \        V n        \        VP                  VP                  VP                  4      V n	        V # )zb
In-place pair-wise combine two equal length cyclers (zip).

Parameters
----------
other : Cycler
z"Cannot += with a non-Cycler object)
r   r   	TypeErrorr"   r   r#   r   r?   r!   r    r   rA   Zold_self   && r   __iadd__ZCycler.__iadd__#  sc     %((@AA99T?"83

U[[%,,		Br   c                rF   )zd
In-place outer product of two cyclers (`itertools.product`).

Parameters
----------
other : Cycler
z"Cannot *= with a non-Cycler object)
r   r   rG   r"   r   r#   r   r   r!   r    rH   rI   r   __imul__ZCycler.__imul__5  sc     %((@AA99T?"83

U[[%,,		Br   c                s   \        V 4      \        V4      8w  d   R # V P                  VP                  ,          '       d   R # \        ;QJ d%    R \        W4       4       F  '       d   K   R # 	  R# ! R \        W4       4       4      # )Fc              3   s.   "   T F  w  rW8H  x  K  	  R # 5ir   r,   )r   r9   r:      &  r   r   Z Cycler.__eq__.<locals>.<genexpr>L  s     7&6da16&6s   T)r>   r   Zallr?   r@   r'   r   __eq__ZCycler.__eq__G  s^    t9E
"99uzz!!s7c$&67ss7s7s7c$&6777r   c                s    W8X  * # r   r,   r@   r'   r   __ne__ZCycler.__ne__N  s    ""r   c                s:  a \         R \        R/pV P                  f;   V P                  P	                  4       o\        V3R lV  4       4      pRS: RV: R2# VP                  V P                  R4      pRpVP                  V P                  W0P                  R7      # )	Z+Z*c              3   4   <"   T F  qS,          x  K  	  R # 5ir   r,   r   r%   labr.   r   r   Z"Cycler.__repr__.<locals>.<genexpr>W  s     ,t!vvt   zcycler(z, Z)Z?z({left!r} {op} {right!r}))r	   r$   r
   )
r?   r   r    r   popr/   Zgetr!   r   r   )r   Zop_mapr0   r$   msgrQ   s   &    @r   __repr__ZCycler.__repr__S  s    sGS);;))--/C,t,,CSG2cWA..DHHc*B-C::4::"KK:HHr   c                s   R p\        V P                  \        R7      pV F  pVRV: R2,          pK  	  \        V 4       F2  pVR,          pV F  pVRWE,          : R2,          pK  	  VR,          pK4  	  VR,          pV# )	z<table>)r2   z<th>z</th>z<tr>z<td>z</td>z</tr>z</table>)Zsortedr   Zreprr   )r   ZoutputZsorted_keysr2   dr   s   &     r   _repr_html_ZCycler._repr_html_^  s    TYYD1CSG5))F dAfF D.. !gF	 
 	*r   c                s    V P                   pV Uu/ uF  q"\        4       bK  	  ppV  F)  pV F   pW2,          P                  WB,          4       K"  	  K+  	  V# u upi )a}  
Values by key.

This returns the transposed values of the cycler.  Iterating
over a `Cycler` yields dicts with a single value for each key,
this method returns a `dict` of `list` which are the values
for the given key.

The returned value can be used to create an equivalent `Cycler`
using only `+`.

Returns
-------
transpose : dict
    dict of lists of the values for each key.
)r   r/   Zappend)r   r   r   r;   rV   r<   r   r   ZCycler.by_keyl  sU    * yy"&'$Q$&y$'Aad#   
 (s   Ac                sl    V P                  4       p\        \        R VP                  4        4       4      # )z_
Simplify the cycler into a sum (but no products) of cyclers.

Returns
-------
simple : Cycler
c              3   <   "   T F  w  r\        W4      x  K  	  R # 5ir   r   r   r   r%   rL   r   r   Z"Cycler.simplify.<locals>.<genexpr>  s     DmdaGAMMm   )r   r    r   r5   )r   r6   s   & r   simplifyZCycler.simplify  s(     cDekkmDEEr   )r#   r   r!   r    )NN) Z__name__Z
__module__Z__qualname__Z__firstlineno____doc__r   r&   r(   Zpropertyr   r+   Zclassmethodr1   r8   r=   rB   rC   rD   rE   rJ   rK   rM   rN   Z__hash__rU   rW   r   Z
_transposer[   r   Z__static_attributes__Z__classdictcell__)Z__classdict__s   @r   r   r   h   s     66  "EH  0L	(""/$$8# H	I< JF  Fr   r   c                 s   V '       d   V'       d   \        R4      h\        V 4      ^8X  d;   \        V ^ ,          \        4      '       g   \        R4      h\        V ^ ,          4      # \        V 4      ^8X  d
   \	        V !  # \        V 4      ^8  d   \        R4      hV'       d&   \        \        R VP                  4        4       4      # \        R4      h)aw  
Create a new `Cycler` object from a single positional argument,
a pair of positional arguments, or the combination of keyword arguments.

cycler(arg)
cycler(label1=itr1[, label2=iter2[, ...]])
cycler(label, itr)

Form 1 simply copies a given `Cycler` object.

Form 2 composes a `Cycler` as an inner product of the
pairs of keyword arguments. In other words, all of the
iterables are cycled simultaneously, as if through zip().

Form 3 creates a `Cycler` from a label and an iterable.
This is useful for when the label cannot be a keyword argument
(e.g., an integer or a name that has a space in it).

Parameters
----------
arg : Cycler
    Copy constructor for Cycler (does a shallow copy of iterables).
label : name
    The property key. In the 2-arg form of the function,
    the label can be any hashable object. In the keyword argument
    form of the function, it must be a valid python identifier.
itr : iterable
    Finite length iterable of the property values.
    Can be a single-property `Cycler` that would
    be like a key change, but as a shallow copy.

Returns
-------
cycler : Cycler
    New `Cycler` for the given property

zBcyl() can only accept positional OR keyword arguments -- not both.zDIf only one positional argument given, it must be a Cycler instance.zdOnly a single Cycler can be accepted as the lone positional argument. Use keyword arguments instead.c              3   rX   r   r   rY   rL   r   r   Zcycler.<locals>.<genexpr>  s     EndaGAMMnrZ   z4Must have at least a positional OR keyword arguments)rG   r>   r   r   r   r    r   r5   )ZargsZkwargss   *,r   cyclerr]     s    L  1 2 	2 4yA~$q'6** 4 5 5d1g	Ta~	TQ N O 	O cEfllnEFF
J
KKr   c                s   a \        V\        4      '       dF   VP                  p\        V4      ^8w  d   Rp\	        V4      hVP                  4       oV3R lV 4       p\        P                  W4      # )a  
Create a new `Cycler` object from a property name and iterable of values.

Parameters
----------
label : hashable
    The property key.
itr : iterable
    Finite length iterable of the property values.

Returns
-------
cycler : Cycler
    New `Cycler` for the given property
z2Can not create Cycler from a multi-property Cyclerc              3   rO   r   r,   rP   r.   r   r   Z_cycler.<locals>.<genexpr>  s     #s!vvsrR   )r   r   r   r>   r   rS   r1   )r-   r0   r   rT   rQ   s   &&  @r   r   r     s]      #vxxt9>FCS/!hhj $s#U((r   )r\   r"   Z	functoolsr    Z	itertoolsr   r   Zoperatorr   r   Z__version__r   r   r   r]   r   r,   r   r   <module>r^      sB   (V   $ .G:t tn	8Lv)r   