a
    RG5dE                     @   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/django/DPS/env/lib/python3.9/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   ).0aa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&J 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   %       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>'   r(   z.super_signature.<locals>.<listcomp>.<listcomp>)keyr%   )maxr
   r   r   r,   r	   r.   '   s   z#super_signature.<locals>.<listcomp>)r
   r   ranger   r   )r'   r    r	   super_signature"   s
    
r2   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
    

r3   c                    sb   t tt   fdd D }tdd |} D ]}||v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   )r3   r   r   r   r   r   r	   r.   >   r(   zordering.<locals>.<listcomp>c                 S   s   | d S )Nr%   r   )xr   r   r	   <lambda>?   r(   zordering.<locals>.<lambda>c                 S   s    i | ]\}}|d d |D qS )c                 S   s   g | ]\}}|qS r   r   r4   r   r   r	   r.   C   r(   z'ordering.<locals>.<dictcomp>.<listcomp>r   )r   kvr   r   r	   
<dictcomp>C   r(   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$   r2   r   r3   r<   r   r   r   r	   <module>   s   
	