o
    lôjEA  ã                   @  s  d Z ddlmZ ddlmZmZmZ ddlZddlm	Z	 ddl
mZmZ ddlmZmZ ddlmZmZmZmZmZmZmZmZmZ d	Zed
ed�Zeded�ZedƒZedƒZd+dd„Zd,dd„Z G dd„ deeef ƒZ!ed-dd „ƒZ"ed.d$d „ƒZ"ed/d'd „ƒZ"d(d „ Z"d/d)d*„Z#dS )0a’  
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ÚUÚleftú#Cycler[K, V] | Iterable[dict[K, V]]Úrightú*Cycler[K, V] | Iterable[dict[K, V]] | NoneÚreturnúset[K]c                 C  s`   | g kr
t t| ƒƒni }|durt t|ƒƒni }t| ¡ ƒ}t| ¡ ƒ}||@ r,tdƒ‚||B S )a  
    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.
    Nz"Can not compose overlapping cycles)ÚnextÚiterÚsetÚkeysÚ
ValueError)r   r   Zl_peekZr_peekZl_keyZr_key© r$   úb/var/www/html/academy/tools/voices/clone/cosy-venv/lib/python3.10/site-packages/cycler/__init__.pyÚ_process_keys>   s   r&   úCycler[K, V]úCycler[K, U]úCycler[K, V | U]c                   sŽ   | j |j krtdj| j |j @ | j |j A d�ƒ‚ttttttt	f  f |  
¡ ƒ‰ ttttttt	f  f | 
¡ ƒ‰tt‡ ‡fdd„| j D ƒƒS )aS  
    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})ÚbothZjust_onec                 3  s&   � | ]}t |ˆ | ˆ|  ƒV  qd S ©N©Ú_cycler©Ú.0Úk©Ú_lÚ_rr$   r%   Ú	<genexpr>t   s   €$ zconcat.<locals>.<genexpr>)r"   r#   Úformatr   r   r   r   r   r   r   Úby_keyr   r
   )r   r   r$   r1   r%   ÚconcatX   s   ýÿ""r7   c                   @  s  e Zd ZdZdd„ Z		dIdJdd„Zdd„ ZedKdd„ƒZdLdd„Z	e
dMdd„ƒZdNd!d"„ZdOd$d%„ZdPd)d*„ZedPd+d,„ƒZedQd.d,„ƒZd/d,„ ZedPd0d1„ƒZedQd2d1„ƒZd3d1„ ZdRd4d5„ZdSd6d7„ZdTd9d:„ZdUd=d>„ZdZdVd@dA„ZdVdBdC„ZdWdEdF„ZeZdXdGdH„ZeZdS )YÚ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                 C  s   t | ƒS r+   )r   ©Úselfr$   r$   r%   Ú__call__“   ó   zCycler.__call__Nr   r   r   úCycler[K, V] | NoneÚopr   c                 C  s€   t |tƒrt|j|j|jƒ| _n|durdd„ |D ƒ| _ng | _t |tƒr0t|j|j|jƒ| _nd| _t| j| jƒ| _|| _dS )zf
        Semi-private init.

        Do not use this directly, use `cycler` function instead.
        Nc                 S  s   g | ]}t   |¡‘qS r$   )Úcopy©r/   Úvr$   r$   r%   Ú
<listcomp>¨   s    z#Cycler.__init__.<locals>.<listcomp>)Ú
isinstancer8   Ú_leftÚ_rightÚ_opr&   Ú_keys)r:   r   r   r>   r$   r$   r%   Ú__init__–   s   
ÿ
ÿ
zCycler.__init__c                 C  s
   || j v S r+   )rG   )r:   r0   r$   r$   r%   Ú__contains__¶   s   
zCycler.__contains__r   r   c                 C  s
   t | jƒS )z!The keys this Cycler knows about.)r!   rG   r9   r$   r$   r%   r"   ¹   s   
zCycler.keysÚoldr   ÚnewÚNonec                   sÒ   ˆˆ krdS ˆ | j v rtdˆ› dˆ › dˆ › d�ƒ‚ˆ| j vr,tdˆ› dˆ › dˆ› d�ƒ‚| j  ˆ¡ | j  ˆ ¡ | jdurLˆ| jjv rL| j ˆˆ ¡ dS t| j	t
ƒr[| j	 ˆˆ ¡ dS ‡ ‡fdd„| j	D ƒ| _	dS )	a  
        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 keyc                   s   g | ]}ˆ |ˆ i‘qS r$   r$   )r/   Úentry©rK   rJ   r$   r%   rB   à   s    z%Cycler.change_key.<locals>.<listcomp>)rG   r#   ÚKeyErrorÚremover
   rE   r"   Ú
change_keyrC   rD   r8   )r:   rJ   rK   r$   rO   r%   rR   ¾   s"   	
ÿ
ÿzCycler.change_keyÚlabelÚitrúIterable[V]r'   c                   s,   | dƒ}t ‡ fdd„|D ƒƒ|_ˆ h|_|S )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  s   � | ]}ˆ |iV  qd S r+   r$   r@   ©rS   r$   r%   r4   ÷   ó   € z$Cycler._from_iter.<locals>.<genexpr>)ÚlistrD   rG   )ÚclsrS   rT   Úretr$   rV   r%   Ú
_from_iterâ   s   zCycler._from_iterÚkeyÚslicec                   s6   t ˆ tƒr|  ¡ }tt‡ fdd„| ¡ D ƒƒS tdƒ‚)Nc                 3  s"   � | ]\}}t ||ˆ  ƒV  qd S r+   r,   ©r/   r0   rA   ©r\   r$   r%   r4   ÿ   ó   €  z%Cycler.__getitem__.<locals>.<genexpr>z+Can only use slices with Cycler.__getitem__)rC   r]   r6   r   r
   Úitemsr#   )r:   r\   Útransr$   r_   r%   Ú__getitem__û   s   
zCycler.__getitem__ú!Generator[dict[K, V], None, None]c                 c  st   � | j d u r| jD ]}t|ƒV  q	d S | jd u rtdƒ‚|  | j| j ¡D ]\}}i }| |¡ | |¡ |V  q$d S )Nz=Operation cannot be None when both left and right are defined)rE   rD   ÚdictrF   Ú	TypeErrorÚupdate)r:   r   ÚaÚbÚoutr$   r$   r%   Ú__iter__  s   €

ÿ
ÿ

üzCycler.__iter__ÚotherúCycler[L, U]úCycler[K | L, V | U]c                 C  st   t | ƒt |ƒkrtdt | ƒ› dt |ƒ› �ƒ‚ttttttf tttf f | ƒtttttf tttf f |ƒt	ƒS )z�
        Pair-wise combine two equal length cyclers (zip).

        Parameters
        ----------
        other : Cycler
        z&Can only add equal length cycles, not z and )
Úlenr#   r8   r   r   r   r   r   r   Úzip©r:   rl   r$   r$   r%   Ú__add__  s   ÿ  ýzCycler.__add__c                 C  ó   d S r+   r$   rq   r$   r$   r%   Ú__mul__$  ó   zCycler.__mul__Úintc                 C  rs   r+   r$   rq   r$   r$   r%   rt   (  ru   c                   s„   t ˆ tƒr)ttttttf tttf f | ƒtttttf tttf f ˆ ƒtƒS t ˆ t	ƒr@|  
¡ }tt‡ fdd„| ¡ D ƒƒS tS )z¬
        Outer product of two cyclers (`itertools.product`) or integer
        multiplication.

        Parameters
        ----------
        other : Cycler or int
        c                 3  s"   � | ]\}}t ||ˆ  ƒV  qd S r+   r,   r^   ©rl   r$   r%   r4   >  r`   z!Cycler.__mul__.<locals>.<genexpr>)rC   r8   r   r   r   r   r   r   r   rv   r6   r   r
   ra   ÚNotImplemented)r:   rl   rb   r$   rw   r%   rt   ,  s   
	  ý
ÿc                 C  rs   r+   r$   rq   r$   r$   r%   Ú__rmul__C  ru   zCycler.__rmul__c                 C  rs   r+   r$   rq   r$   r$   r%   ry   G  ru   c                 C  s   | | S r+   r$   rq   r$   r$   r%   ry   K  r<   c                 C  sD   t ttti}| jd u rt| jƒS t| jƒ}t| jƒ}|| j ||ƒS r+   )rp   Úminr   r	   rE   ro   rD   rF   )r:   Zop_dictZl_lenZr_lenr$   r$   r%   Ú__len__N  s   



zCycler.__len__c                 C  óL   t |tƒs	tdƒ‚t | ¡}t||ƒ| _|| _t| _t|j|j	|jƒ| _	| S )zŠ
        In-place pair-wise combine two equal length cyclers (zip).

        Parameters
        ----------
        other : Cycler
        z"Cannot += with a non-Cycler object)
rC   r8   rf   r?   r&   rG   rD   rp   rF   rE   ©r:   rl   Zold_selfr$   r$   r%   Ú__iadd__X  ó   

zCycler.__iadd__úCycler[K, V] | intc                 C  r|   )zŒ
        In-place outer product of two cyclers (`itertools.product`).

        Parameters
        ----------
        other : Cycler
        z"Cannot *= with a non-Cycler object)
rC   r8   rf   r?   r&   rG   rD   r   rF   rE   r}   r$   r$   r%   Ú__imul__j  r   zCycler.__imul__ÚobjectÚboolc                 C  sJ   t |tƒsdS t| ƒt|ƒkrdS | j|jA rdS tdd„ t| |ƒD ƒƒS )NFc                 s  s   � | ]	\}}||kV  qd S r+   r$   )r/   rh   ri   r$   r$   r%   r4   ƒ  s   € z Cycler.__eq__.<locals>.<genexpr>)rC   r8   ro   r"   Úallrp   rq   r$   r$   r%   Ú__eq__|  s   
zCycler.__eq__Ústrc                   sn   t dtdi}| jd u r$| j ¡ ‰ t‡ fdd„| D ƒƒ}dˆ ›d|›d�S | | jd¡}d	}|j| j	|| jd
�S )Nú+Ú*c                 3  ó   � | ]}|ˆ  V  qd S r+   r$   r@   ©Úlabr$   r%   r4   ‹  rW   z"Cycler.__repr__.<locals>.<genexpr>zcycler(rM   ú)Ú?z({left!r} {op} {right!r}))r   r>   r   )
rp   r   rE   r"   ÚpoprX   ÚgetrF   r5   rD   )r:   Zop_maprT   r>   Úmsgr$   rŠ   r%   Ú__repr__‡  s   

zCycler.__repr__c                 C  st   d}t | jtd�}|D ]
}|d|›d�7 }qt| ƒD ]}|d7 }|D ]}|d|| ›d�7 }q"|d7 }q|d	7 }|S )
Nz<table>r_   z<th>z</th>z<tr>z<td>z</td>z</tr>z</table>)Úsortedr"   Úreprr    )r:   ÚoutputÚsorted_keysr\   Údr0   r$   r$   r%   Ú_repr_html_’  s   
zCycler._repr_html_údict[K, list[V]]c                 C  s>   | j }dd„ |D ƒ}| D ]}|D ]}||  || ¡ qq|S )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.
        c                 S  s   i | ]}|t ƒ “qS r$   )rX   r.   r$   r$   r%   Ú
<dictcomp>¶  s    z!Cycler.by_key.<locals>.<dictcomp>)r"   Úappend)r:   r"   rj   r–   r0   r$   r$   r%   r6      s   ÿzCycler.by_keyc                 C  s    |   ¡ }ttdd„ | ¡ D ƒƒS )z‡
        Simplify the cycler into a sum (but no products) of cyclers.

        Returns
        -------
        simple : Cycler
        c                 s  ó   � | ]
\}}t ||ƒV  qd S r+   r,   r^   r$   r$   r%   r4   Î  ó   € z"Cycler.simplify.<locals>.<genexpr>)r6   r   r
   ra   )r:   rb   r$   r$   r%   ÚsimplifyÀ  s   zCycler.simplify)NN)r   r   r   r=   r>   r   )r   r   )rJ   r   rK   r   r   rL   ©rS   r   rT   rU   r   r'   )r\   r]   r   r'   )r   rd   )rl   rm   r   rn   )rl   rv   r   r'   )r   rv   )rl   r'   r   r'   )rl   r€   r   r'   )rl   r‚   r   rƒ   )r   r†   )r   r˜   )r   r'   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r;   rH   rI   Úpropertyr"   rR   Úclassmethodr[   rc   rk   rr   r   rt   ry   r{   r~   r�   r…   Ú__hash__r‘   r—   r6   Ú
_transposer�   r7   r$   r$   r$   r%   r8   w   sH    ü 
$







	



r8   Úargc                 C  rs   r+   r$   )r§   r$   r$   r%   ÚcyclerÓ  ru   r¨   ÚkwargsrU   úCycler[str, V]c                  K  rs   r+   r$   )r©   r$   r$   r%   r¨   Ø  ru   rS   rT   c                 C  rs   r+   r$   )rS   rT   r$   r$   r%   r¨   Ý  ru   c                  O  sŠ   | r|rt dƒ‚t| ƒdkrt| d tƒst dƒ‚t| d ƒS t| ƒdkr)t| Ž S t| ƒdkr3t dƒ‚|rAttdd„ | ¡ D ƒƒS t d	ƒ‚)
aë  
    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                 s  r›   r+   r,   r^   r$   r$   r%   r4     rœ   zcycler.<locals>.<genexpr>z4Must have at least a positional OR keyword arguments)rf   ro   rC   r8   r-   r   r
   ra   )Úargsr©   r$   r$   r%   r¨   â  s&   &ÿÿÿc                   sN   t |tƒr!|j}t|ƒdkrd}t|ƒ‚| ¡ ‰ ‡ fdd„|D ƒ}t | |¡S )aD  
    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  r‰   r+   r$   r@   rŠ   r$   r%   r4   ;  rW   z_cycler.<locals>.<genexpr>)rC   r8   r"   ro   r#   rŽ   r[   )rS   rT   r"   r�   r$   rŠ   r%   r-   "  s   
r-   )r   r   r   r   r   r   )r   r'   r   r(   r   r)   )r§   r'   r   r'   )r©   rU   r   rª   rž   )$r¢   Ú
__future__r   Úcollections.abcr   r   r   r?   Ú	functoolsr   Ú	itertoolsr   r   Úoperatorr	   r
   Útypingr   r   r   r   r   r   r   r   r   Ú__version__r   r   r   r   r&   r7   r8   r¨   r-   r$   r$   r$   r%   Ú<module>   s4    +,

  ^@