U
    ZÊ¹jE  ã                   @   s`   d dl mZmZ G dd„ deƒZdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	e
fdd„Zdd„ ZdS )é   )Ú	_toposortÚgroupbyc                   @   s   e Zd ZdS )ÚAmbiguityWarningN)Ú__name__Ú
__module__Ú__qualname__© r   r   ú^/var/www/html/bwave/python/venv/lib/python3.8/site-packages/sympy/multipledispatch/conflict.pyr      s   r   c                 C   s    t | ƒt |ƒkottt| |ƒƒS )z3 A is consistent and strictly more specific than B )ÚlenÚallÚmapÚ
issubclass©ÚaÚbr   r   r	   Ú
supercedes   s    r   c                 C   s(   t | ƒt |ƒko&tdd„ t| |ƒD ƒƒS )z= It is possible for an argument list to satisfy both A and B c                 s   s&   | ]\}}t ||ƒpt ||ƒV  qd S ©N)r   )Ú.0ZaaZbbr   r   r	   Ú	<genexpr>   s   ÿzconsistent.<locals>.<genexpr>)r
   r   Úzipr   r   r   r	   Ú
consistent   s
    ÿÿr   c                 C   s    t | |ƒot| |ƒpt|| ƒ S )z> A is consistent with B but neither is strictly more specific )r   r   r   r   r   r	   Ú	ambiguous   s    r   c                    s    t ttˆ ƒƒ‰ ‡ fdd„ˆ D ƒS )z5 All signature pairs such that A is ambiguous with B c                    sP   h | ]H‰ ˆD ]>‰t ˆ ƒt ˆƒk rtˆ ˆƒrt‡ ‡fd d„ˆD ƒƒsˆ ˆf’qqS )c                 3   s"   | ]}t |ˆ ƒot |ˆƒV  qd S r   ©r   )r   Úcr   r   r	   r      s   ÿz(ambiguities.<locals>.<setcomp>.<genexpr>)Úhashr   Úany©r   ©Ú
signaturesr   r	   Ú	<setcomp>   s      
ÿýzambiguities.<locals>.<setcomp>)Úlistr   Útupler   r   r   r	   Úambiguities   s    r"   c                    s<   t ˆd ƒ‰ t‡ fdd„ˆD ƒƒs&t‚‡fdd„tˆ ƒD ƒS )z* A signature that would break ambiguities é    c                 3   s   | ]}t |ƒˆ kV  qd S r   )r
   )r   Ús)Únr   r	   r   %   s     z"super_signature.<locals>.<genexpr>c                    s*   g | ]"‰ t ‡ fd d„ˆD ƒtd�d ‘qS )c                    s   g | ]}t  |ˆ  ¡‘qS r   )ÚtypeÚmro)r   Úsig©Úir   r	   Ú
<listcomp>'   s     z.super_signature.<locals>.<listcomp>.<listcomp>)Úkeyr#   )Úmaxr
   r   r   r)   r	   r+   '   s   ÿz#super_signature.<locals>.<listcomp>)r
   r   ÚAssertionErrorÚranger   r   )r%   r   r	   Úsuper_signature"   s
    
ÿr0   c                 C   s,   t | |ƒr(t || ƒr$|| ƒ||ƒkS dS dS )zW A should be checked before B

    Tie broken by tie_breaker, defaults to ``hash``
    TFr   )r   r   Ztie_breakerr   r   r	   Úedge+   s
    

r1   c                    sb   t ttˆ ƒƒ‰ ‡ fdd„ˆ D ƒ}tdd„ |ƒ}ˆ D ]}||kr2g ||< q2dd„ | ¡ D ƒ}t|ƒS )zƒ A sane ordering of signatures to check, first to last

    Topoological sort of edges as given by ``edge`` and ``supercedes``
    c                    s(   g | ] }ˆ D ]}t ||ƒr||f‘qqS r   )r1   ©r   r   r   r   r   r	   r+   >   s
       
 zordering.<locals>.<listcomp>c                 S   s   | d S )Nr#   r   )Úxr   r   r	   Ú<lambda>?   ó    zordering.<locals>.<lambda>c                 S   s    i | ]\}}|d d„ |D ƒ“qS )c                 S   s   g | ]\}}|‘qS r   r   r2   r   r   r	   r+   C   s     z'ordering.<locals>.<dictcomp>.<listcomp>r   )r   ÚkÚvr   r   r	   Ú
<dictcomp>C   s      zordering.<locals>.<dictcomp>)r    r   r!   r   Úitemsr   )r   Úedgesr$   r   r   r	   Úordering8   s    
r;   N)Úutilsr   r   ÚWarningr   r   r   r   r"   r0   r   r1   r;   r   r   r   r	   Ú<module>   s   
	