
    MZdE                     X    d dl mZmZ  G d de      Zd Zd Zd Zd Zd Z	e
fd	Zd
 Zy)   )	_toposortgroupbyc                       e Zd Zy)AmbiguityWarningN)__name__
__module____qualname__     A/usr/lib/python3/dist-packages/sympy/multipledispatch/conflict.pyr   r      s    r   r   c                 h    t        |       t        |      k(  xr t        t        t        | |            S )z3 A is consistent and strictly more specific than B )lenallmap
issubclassabs     r   
supercedesr      s(    q6SV:C
Aq$9 ::r   c                 l    t        |       t        |      k(  xr t        d t        | |      D              S )z= It is possible for an argument list to satisfy both A and B c              3   V   K   | ]!  \  }}t        ||      xs t        ||       # y wN)r   ).0aabbs      r   	<genexpr>zconsistent.<locals>.<genexpr>   s2      4%r2 2r"8jR&88 4s   '))r   r   zipr   s     r   
consistentr      s7    Fc!f 4 4),Q4 45r   c                 T    t        | |      xr t        | |      xs t        ||        S )z> A is consistent with B but neither is strictly more specific )r   r   r   s     r   	ambiguousr       s*    aJZ1%5%IAq9I JJr   c           	          t        t        t        |             } | D ch c]E  | D ]>  t              t              k  r%t	              rt        fd| D              sf@ G c}}S c c}}w )z5 All signature pairs such that A is ambiguous with B c              3   R   K   | ]  }t        |      xr t        |         y wr   r   )r   cr   r   s     r   r   zambiguities.<locals>.<genexpr>   s/      #9() $.a#3#H
1a8H#H #9s   $')listr   tuplehashr    any)
signaturesr   r   s    ``r   ambiguitiesr*      sz    c%,-J& : :q
 :1q'DG+$Q?" #9-7#9  9 F :F : : :s   A
A1c                    t        | d         t        fd| D              sJ t              D cg c]:  }t        | D cg c]  }t        j                  ||          c}t               d   < c}}S c c}w c c}}w )z* A signature that would break ambiguities     c              3   :   K   | ]  }t        |      k(    y wr   )r   )r   sns     r   r   z"super_signature.<locals>.<genexpr>%   s     /qs1v{/s   )key)r   r   rangemaxtypemro)r)   isigr/   s      @r   super_signaturer7   "   sr    JqMA/J//// a" Z8c#a&!8cB1E " "8 "s   A<A7!A<7A<c                 X    t        | |      rt        ||       r ||        ||      kD  S yy)zW A should be checked before B

    Tie broken by tie_breaker, defaults to ``hash``
    TFr#   )r   r   tie_breakers      r   edger:   +   s1    
 !Qaq>KN22r   c                 p   t        t        t        |             } | D cg c]  }| D ]  }t        ||      s||f  }}}t	        d |      }| D ]  }||vsg ||<    |j                         D ci c]  \  }}||D cg c]  \  }}|	 c}} }}}}}t        |      S c c}}w c c}}w c c}}}}w )z A sane ordering of signatures to check, first to last

    Topoological sort of edges as given by ``edge`` and ``supercedes``
    c                     | d   S )Nr,   r
   )xs    r   <lambda>zordering.<locals>.<lambda>?   s
    ad r   )r%   r   r&   r:   r   itemsr   )r)   r   r   edgesr.   kvs          r   orderingrC   8   s    
 c%,-J'JJAtAqzaVJVJEJNE*E E>E!H /4kkm<<daQq!tq!!!<E<U K
 "<s"   B$B$4B0
B*B0
*B0
N)utilsr   r   Warningr   r   r   r    r*   r7   r'   r:   rC   r
   r   r   <module>rF      s=    %	w 	;
5K
:"   
r   