a
    ¬<bE  ć                   @   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   śo/Users/vegardjervell/Documents/master/model/venv/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   )Ś.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&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
    
’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 ]}||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   )r1   ©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   r2   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"   r0   r   r1   r:   r   r   r   r	   Ś<module>   s   
	