ó
Ąž\c           @   sr   d  d l  m Z m Z d e f d     YZ d   Z d   Z d   Z d   Z d   Z	 e
 d	  Z d
   Z d S(   i   (   t	   _toposortt   groupbyt   AmbiguityWarningc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s>   lib/python2.7/site-packages/sympy/multipledispatch/conflict.pyR      s   c         C   s.   t  |   t  |  k o- t t t |  |   S(   s3    A is consistent and strictly more specific than B (   t   lent   allt   mapt
   issubclass(   t   at   b(    (    s>   lib/python2.7/site-packages/sympy/multipledispatch/conflict.pyt
   supercedes   s    c         C   s5   t  |   t  |  k o4 t d   t |  |  D  S(   s=    It is possible for an argument list to satisfy both A and B c         s   s3   |  ]) \ } } t  | |  p* t  | |  Vq d  S(   N(   R   (   t   .0t   aat   bb(    (    s>   lib/python2.7/site-packages/sympy/multipledispatch/conflict.pys	   <genexpr>   s   (   R   R   t   zip(   R	   R
   (    (    s>   lib/python2.7/site-packages/sympy/multipledispatch/conflict.pyt
   consistent   s    	c         C   s,   t  |  |  o+ t |  |  p* t | |   S(   s>    A is consistent with B but neither is strictly more specific (   R   R   (   R	   R
   (    (    s>   lib/python2.7/site-packages/sympy/multipledispatch/conflict.pyt	   ambiguous   s    c            s   t  t t |    }  t g  |  D]f   |  D]Y  t    t   k  r) t     r) t    f d   |  D  r)    f ^ q) q  S(   s5    All signature pairs such that A is ambiguous with B c         3   s-   |  ]# } t  |    o$ t  |   Vq d  S(   N(   R   (   R   t   c(   R	   R
   (    s>   lib/python2.7/site-packages/sympy/multipledispatch/conflict.pys	   <genexpr>   s   (   t   listR   t   tuplet   sett   hashR   t   any(   t
   signatures(    (   R	   R
   s>   lib/python2.7/site-packages/sympy/multipledispatch/conflict.pyt   ambiguities   s    c            s   t  |  d    t   f d   |  D  s2 t  g  t    D]< } t g  |  D] } t j | |  ^ qO d t  d ^ q? S(   s*    A signature that would break ambiguities i    c         3   s!   |  ] } t  |    k Vq d  S(   N(   R   (   R   t   s(   t   n(    s>   lib/python2.7/site-packages/sympy/multipledispatch/conflict.pys	   <genexpr>%   s    t   key(   R   R   t   AssertionErrort   ranget   maxt   typet   mro(   R   t   it   sig(    (   R   s>   lib/python2.7/site-packages/sympy/multipledispatch/conflict.pyt   super_signature"   s    "c         C   s?   t  |  |  r; t  | |   r4 | |   | |  k St Sn  t S(   sW    A should be checked before B

    Tie broken by tie_breaker, defaults to ``hash``
    (   R   t   Truet   False(   R	   R
   t   tie_breaker(    (    s>   lib/python2.7/site-packages/sympy/multipledispatch/conflict.pyt   edge+   s
    c         C   sē   t  t t |    }  g  |  D]. } |  D]! } t | |  r& | | f ^ q& q } t d   |  } x' |  D] } | | k ri g  | | <qi qi Wt d   | j   D  } t |  S(   s    A sane ordering of signatures to check, first to last

    Topoological sort of edges as given by ``edge`` and ``supercedes``
    c         S   s   |  d S(   Ni    (    (   t   x(    (    s>   lib/python2.7/site-packages/sympy/multipledispatch/conflict.pyt   <lambda>?   t    c         s   s:   |  ]0 \ } } | g  | D] \ } } | ^ q f Vq d  S(   N(    (   R   t   kt   vR	   R
   (    (    s>   lib/python2.7/site-packages/sympy/multipledispatch/conflict.pys	   <genexpr>C   s    (   R   R   R   R(   R   t   dictt   itemsR    (   R   R	   R
   t   edgesR   (    (    s>   lib/python2.7/site-packages/sympy/multipledispatch/conflict.pyt   ordering8   s    ;N(   t   utilsR    R   t   WarningR   R   R   R   R   R$   R   R(   R1   (    (    (    s>   lib/python2.7/site-packages/sympy/multipledispatch/conflict.pyt   <module>   s   				
		