
    hEA                    T   S r SSKJr  SSKJrJrJr  SSKrSSKJ	r	  SSK
JrJr  SSKJrJr  SSKJrJrJrJrJrJrJrJrJr  S	r\" S
\S9r\" S\S9r\" S5      r\" S5      r      SS jrSS jr  " S S\\\4   5      r!\SS j5       r"\SS j5       r"\SS j5       r"S r"SS jr#g)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': '-.'}
    )annotations)HashableIterable	GeneratorN)reduce)productcycle)muladd)	TypeVarGenericCallableUnionDictListAnyoverloadcastz0.12.1K)boundLVUc                    U / :w  a  [        [        U 5      5      O0 nUb  [        [        U5      5      O0 n[        UR                  5       5      n[        UR                  5       5      nXE-  (       a  [	        S5      eXE-  $ )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)nextitersetkeys
ValueError)leftrightl_peekr_peekl_keyr_keys         A/var/www/html/env/lib/python3.13/site-packages/cycler/__init__.py_process_keysr'   >   sh    " .2RZd4j)RF.3.?d5k*RF&E&E}=>>=    c                  ^^ U R                   UR                   :w  aG  [        SR                  U R                   UR                   -  U R                   UR                   -  S95      e[        [        [
        [        [        [        [        4      4   U R                  5       5      m[        [        [
        [        [        [        [        4      4   UR                  5       5      m[        [        UU4S jU R                    5       5      $ )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})bothjust_onec              3  N   >#    U  H  n[        UTU   TU   -   5      v   M     g 7fN_cycler).0k_l_rs     r&   	<genexpr>concat.<locals>.<genexpr>t   s'     E9a2a52a5=119s   "%)r   r   formatr   r   r   r   r   r   r   by_keyr   r   )r    r!   r2   r3   s     @@r&   concatr8   X   s    $ yyEJJ''-vYY+dii%**6L (. (
 	
 
d1d5A;''($++-	8B	d1d5A;''(%,,.	9B#E499EFFr(   c                  H   \ rS rSrSrS r  S     SS jjrS r\SS j5       r	SS jr
\S S	 j5       rS!S
 jrS"S jrS#S jr\S#S j5       r\S$S j5       rS r\S#S j5       r\S$S j5       rS rS%S jrS&S jrS'S jrS(S jrSrS)S jrS)S jrS*S jr\rS+S jr\rSrg),Cyclerw   a  
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                    [        U 5      $ r-   )r	   selfs    r&   __call__Cycler.__call__   s    T{r(   Nc                   [        U[        5      (       a1  [        UR                  UR                  UR                  5      U l        O7Ub-  U Vs/ s H  n[
        R
                  " U5      PM     snU l        O/ U l        [        U[        5      (       a1  [        UR                  UR                  UR                  5      U l        OSU l        [        U R                  U R                  5      U l        X0l        gs  snf )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__Cycler.__init__   s     dF##:@

DKK;DJ  1551$))A,5DJDJeV$$/5U\\5990DK DK*4::t{{C
 6s    C7c                    XR                   ;   $ r-   )rG   )r>   r1   s     r&   __contains__Cycler.__contains__   s    JJr(   c                ,    [        U R                  5      $ )z!The keys this Cycler knows about.)r   rG   r=   s    r&   r   Cycler.keys   s     4::r(   c           	     Z   X:X  a  gX R                   ;   a  [        SU SU SU S35      eXR                   ;  a  [        SU SU SU S35      eU R                   R                  U5        U R                   R	                  U5        U R
                  b5  XR
                  R                  ;   a  U R
                  R                  X5        g[        U R                  [        5      (       a  U R                  R                  X5        gU R                   Vs/ s H  o2X1   0PM
     snU l	        gs  snf )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.
NzCan't replace z with , z is already a keyz is not a key)rG   r   KeyErrorremover   rD   r   
change_keyrB   rC   r:   )r>   oldnewentrys       r&   rU   Cycler.change_key   s    :** VC53%7HI  jj  VC53%}E  	

#

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

F++JJ!!#+
 :>D
+DDJDs   D(c                \   ^ U " S5      n[        U4S jU 5       5      Ul        T1Ul        U$ )a:  
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 : hashable
    The property key.

itr : iterable
    Finite length iterable of the property values.

Returns
-------
`Cycler`
    New 'base' cycler.
Nc              3  ,   >#    U  H	  nTU0v   M     g 7fr-    )r0   rI   labels     r&   r4   $Cycler._from_iter.<locals>.<genexpr>   s     1S%S   )listrC   rG   )clsr]   itrrets    `  r&   
_from_iterCycler._from_iter   s.    (  I1S11	G	
r(   c                   ^ [        T[        5      (       a8  U R                  5       n[        [        U4S jUR                  5        5       5      $ [        S5      e)Nc              3  D   >#    U  H  u  p[        XT   5      v   M     g 7fr-   r.   )r0   r1   rI   keys      r&   r4   %Cycler.__getitem__.<locals>.<genexpr>   s     M}tqS6 2 2}    z+Can only use slices with Cycler.__getitem__)rB   slicer7   r   r   itemsr   )r>   rh   transs    ` r&   __getitem__Cycler.__getitem__   s@    c5!!KKME#Mu{{}MNNJKKr(   c              #  F  #    U R                   c!  U R                   H  n[        U5      v   M     g U R                  c  [	        S5      eU R                  U R                  U R                   5       H-  u  p#0 nUR                  U5        UR                  U5        Uv   M/     g 7f)Nz=Operation cannot be None when both left and right are defined)rD   rC   dictrE   	TypeErrorupdate)r>   r    abouts        r&   __iter__Cycler.__iter__  s     ;;

4j  # xxS  T[[9

1

1		 :s   BB!c           
     n   [        U 5      [        U5      :w  a#  [        S[        U 5       S[        U5       35      e[        [        [        [        [
        [        4   [        [        [        4   4   U 5      [        [        [        [
        [        4   [        [        [        4   4   U5      [        5      $ )zY
Pair-wise combine two equal length cyclers (zip).

Parameters
----------
other : Cycler
z&Can only add equal length cycles, not z and )
lenr   r:   r   r   r   r   r   r   zipr>   others     r&   __add__Cycler.__add__  s     t9E
"8T5UU  adU1a4[0148adU1a4[0159
 	
r(   c                    g r-   r\   r|   s     r&   __mul__Cycler.__mul__$      r(   c                    g r-   r\   r|   s     r&   r   r   (  r   r(   c           
       ^ [        T[        5      (       a{  [        [        [        [        [        [
        4   [        [        [        4   4   U 5      [        [        [        [        [
        4   [        [        [        4   4   T5      [        5      $ [        T[        5      (       a8  U R                  5       n[        [        U4S jUR                  5        5       5      $ [        $ )z|
Outer product of two cyclers (`itertools.product`) or integer
multiplication.

Parameters
----------
other : Cycler or int
c              3  D   >#    U  H  u  p[        XT-  5      v   M     g 7fr-   r.   )r0   r1   rI   r}   s      r&   r4   !Cycler.__mul__.<locals>.<genexpr>>  s     FgaU++rj   )rB   r:   r   r   r   r   r   r   r   intr7   r   r   rl   NotImplemented)r>   r}   rm   s    ` r&   r   r   ,  s     eV$$VE!Q$Kq!t45t<VE!Q$Kq!t45u= 
 s##KKMEFF  "!r(   c                    g r-   r\   r|   s     r&   __rmul__Cycler.__rmul__C  r   r(   c                    g r-   r\   r|   s     r&   r   r   G  r   r(   c                
    X-  $ r-   r\   r|   s     r&   r   r   K  s
    |r(   c                    [         [        [        [        0nU R                  c  [        U R                  5      $ [        U R                  5      n[        U R                  5      nXR                     " X#5      $ r-   )r{   minr   r
   rD   rz   rC   rE   )r>   op_dictl_lenr_lens       r&   __len__Cycler.__len__N  sV    >A3QT=U;;tzz?"DJJDKK xx ..r(   c                   [        U[        5      (       d  [        S5      e[        R                  " U 5      n[	        X!5      U l        X l        [        U l        [        UR                  UR                  UR                  5      U l	        U $ )zb
In-place pair-wise combine two equal length cyclers (zip).

Parameters
----------
other : Cycler
z"Cannot += with a non-Cycler object)
rB   r:   rr   rF   r'   rG   rC   r{   rE   rD   r>   r}   old_selfs      r&   __iadd__Cycler.__iadd__X  sc     %((@AA99T?"83

U[[%,,		Br(   c                   [        U[        5      (       d  [        S5      e[        R                  " U 5      n[	        X!5      U l        X l        [        U l        [        UR                  UR                  UR                  5      U l	        U $ )zd
In-place outer product of two cyclers (`itertools.product`).

Parameters
----------
other : Cycler
z"Cannot *= with a non-Cycler object)
rB   r:   rr   rF   r'   rG   rC   r   rE   rD   r   s      r&   __imul__Cycler.__imul__j  sc     %((@AA99T?"83

U[[%,,		Br(   c                    [        U[        5      (       d  g[        U 5      [        U5      :w  a  gU R                  UR                  -  (       a  g[	        S [        X5       5       5      $ )NFc              3  .   #    U  H  u  pX:H  v   M     g 7fr-   r\   )r0   rt   ru   s      r&   r4    Cycler.__eq__.<locals>.<genexpr>  s     7&6da16&6s   )rB   r:   rz   r   allr{   r|   s     r&   __eq__Cycler.__eq__|  sN    %((t9E
"99uzz!7c$&6777r(   c                2  ^ [         S[        S0nU R                  c:  U R                  R	                  5       m[        U4S jU  5       5      nST< SU< S3$ UR                  U R                  S5      nSnUR                  U R                  X0R                  S	9$ )
N+*c              3  ,   >#    U  H	  oT   v   M     g 7fr-   r\   r0   rI   labs     r&   r4   "Cycler.__repr__.<locals>.<genexpr>  s     ,t!vtr_   zcycler(rR   )?z({left!r} {op} {right!r}))r    rH   r!   )
r{   r   rD   r   popr`   getrE   r6   rC   )r>   op_maprb   rH   msgr   s        @r&   __repr__Cycler.__repr__  s    sGS);;))--/C,t,,CSG2cWA..DHHc*B-C::4::"KK:HHr(   c                    Sn[        U R                  [        S9nU H  nUSU< S3-  nM     [        U 5       H"  nUS-  nU H  nUSXE   < S3-  nM     US-  nM$     US	-  nU$ )
Nz<table>)rh   z<th>z</th>z<tr>z<td>z</td>z</tr>z</table>)sortedr   reprr   )r>   outputsorted_keysrh   dr1   s         r&   _repr_html_Cycler._repr_html_  s    TYYD1CSG5))F dAfF D.. !gF	 
 	*r(   c                    U R                   nU Vs0 s H  o"[        5       _M     nnU  H!  nU H  nX2   R                  XB   5        M     M#     U$ s  snf )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`   append)r>   r   r1   rv   r   s        r&   r7   Cycler.by_key  sU    * yy48 9DqDFD 9Aad#   
 !:s   Ac                l    U R                  5       n[        [        S UR                  5        5       5      $ )z_
Simplify the cycler into a sum (but no products) of cyclers.

Returns
-------
simple : Cycler
c              3  <   #    U  H  u  p[        X5      v   M     g 7fr-   r.   r0   r1   rI   s      r&   r4   "Cycler.simplify.<locals>.<genexpr>  s     DmdaGAMMm   )r7   r   r   rl   )r>   rm   s     r&   simplifyCycler.simplify  s(     cDekkmDEEr(   )rG   rC   rE   rD   )NN)r    *Cycler[K, V] | Iterable[dict[K, V]] | Noner!   zCycler[K, V] | NonerH   r   )returnset[K])rV   r   rW   r   r   Noner]   r   rb   Iterable[V]r   Cycler[K, V])rh   rk   r   r   )r   z!Generator[dict[K, V], None, None])r}   zCycler[L, U]r   zCycler[K | L, V | U])r}   r   r   r   )r   r   )r}   r   r   r   )r}   zCycler[K, V] | intr   r   )r}   objectr   bool)r   str)r   zdict[K, list[V]])r   r   )__name__
__module____qualname____firstlineno____doc__r?   rJ   rM   propertyr   rU   classmethodrd   rn   rw   r~   r   r   r   r   r   r   r   __hash__r   r   r7   
_transposer   r8   __static_attributes__r\   r(   r&   r:   r:   w   s   6 &*	8 # 	@  "EH  0L
$    ".    /$$8 H	I< JF  Fr(   r:   c                    g r-   r\   )args    r&   cyclerr         r(   c                     g r-   r\   )kwargss    r&   r   r     r   r(   c                    g r-   r\   )r]   rb   s     r&   r   r     r   r(   c                    U (       a  U(       a  [        S5      e[        U 5      S:X  a1  [        U S   [        5      (       d  [        S5      e[        U S   5      $ [        U 5      S:X  a  [	        U 6 $ [        U 5      S:  a  [        S5      eU(       a%  [        [        S UR                  5        5       5      $ [        S5      e)	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

zEcycler() can only accept positional OR keyword arguments -- not both.   r   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  <   #    U  H  u  p[        X5      v   M     g 7fr-   r.   r   s      r&   r4   cycler.<locals>.<genexpr>  s     EndaGAMMnr   z4Must have at least a positional OR keyword arguments)rr   rz   rB   r:   r/   r   r   rl   )argsr   s     r&   r   r     s    L S
 	
 4yA~$q'6**(  d1g	Ta~	TQB
 	

 cEfllnEFF
J
KKr(   c                   ^ [        U[        5      (       aD  UR                  n[        U5      S:w  a  Sn[	        U5      eUR                  5       mU4S jU 5       n[        R                  X5      $ )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
r   z2Can not create Cycler from a multi-property Cyclerc              3  ,   >#    U  H	  oT   v   M     g 7fr-   r\   r   s     r&   r4   _cycler.<locals>.<genexpr>;  s     #s!vsr_   )rB   r:   r   rz   r   r   rd   )r]   rb   r   r   r   s       @r&   r/   r/   "  s]      #vxxt9>FCS/!hhj $s#U((r(   )r    z#Cycler[K, V] | Iterable[dict[K, V]]r!   r   r   r   )r    r   r!   zCycler[K, U]r   zCycler[K, V | U])r   r   r   r   )r   r   r   zCycler[str, V]r   )$r   
__future__r   collections.abcr   r   r   rF   	functoolsr   	itertoolsr   r	   operatorr
   r   typingr   r   r   r   r   r   r   r   r   __version__r   r   r   r   r'   r8   r:   r   r/   r\   r(   r&   <module>r      s   (V # 9 9   $  U U UCx Cx CLCL
-5 4G>YWQT] Yx
 
 
 
 
 
 
=L@)r(   