a
    
d<                     @   sd  d dl Z d dlmZmZ d dlmZ d dlmZ dd Zdd Z	d	d
 Z
e jdddidfddddfddidfddidfddgg dddfddgg dddffdd Ze jdddid fd!d"gd d#d$fd%did&fd%did'fd(d d)d*fd+d d)d,fd-d d)d.fd/d d0d!gdgd1d2fd/d d0d!gdgd3d4ff	d5d6 Zd7d8 Zed9gd:d;d< ZdS )=    N)assert_allcloseassert_array_equal)Sankey)check_figures_equalc                  C   s   t  } |   d S )N)r   add)sankey r   e/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/matplotlib/tests/test_sankey.pytest_sankey   s    r
   c                  C   s4   t dgdgdgd} | jd jd  dks0J d S )N      ?First)flowslabelsorientationsr   z
First
0.25r   Zdiagramstextsget_text)sr   r   r	   
test_label   s    r   c                  C   s>   dd } t dgdgdg| d}|jd jd  dks:J d S )	Nc                 S   s   | dS )Nz.3fr   )valuer   r   r	   show_three_decimal_places   s    z=test_format_using_callable.<locals>.show_three_decimal_placesr   r   r   )r   r   r   formatr   zFirst
0.250r   )r   r   r   r   r	   test_format_using_callable   s
    r   zkwargs, msggapr   z'gap' is negative      )r   Zradiusz'radius' is greater than 'gap'Z
head_anglez'head_angle' is negativeZ	tolerancez'tolerance' is negative)r   r   r   r   r   z/The shapes of 'flows' \(2,\) and 'orientations')abc)r   r   z)The shapes of 'flows' \(2,\) and 'labels'c                 C   s@   t jt|d tf i |  W d    n1 s20    Y  d S )Nmatch)pytestraises
ValueErrorr   )kwargsmsgr   r   r	   test_sankey_errors   s    r(   Ztrunklengthz'trunklength' is negative皙?g333333?)r   priorzThe scaled sum of the connectedr*   z*The index of the prior diagram is negativez#The index of the prior diagram is 1)r   r   )connectr*   zAt least one of the connection)r   r   z"The connection index to the source)r      z The connection index to this dia)r   r   皙ɿ)r+   r*   r   r   zThe value of orientations)r+   r*   r   ZpathlengthszThe lengths of 'flows'c                 C   sX   t  }tjt|d0 |jddgd |jf i |  W d    n1 sJ0    Y  d S )Nr!   r)   r-   )r   )r   r#   r$   r%   r   )r&   r'   r   r   r   r	   test_sankey_add_errors.   s    r.   c                  C   s  t g ddgdgdd} |  }t|d jg d |d jg dksJJ tdd	 |d jD sfJ td
d	 |d jD sJ |d j dksJ t	|d j
g d t g ddgdgdd} |  }t|d jg d |d jg dksJ t	|d j
g d d S )N)r         п      ?      Foor   Bar)r   r   r   unitr   )r   r,   r   r,   c                 S   s    g | ]}|  d d dkqS )r   r,   r2   r   .0textr   r   r	   
<listcomp>H       z test_sankey2.<locals>.<listcomp>c                 S   s    g | ]}|  d d dkqS )Nr3   r5   r6   r   r   r	   r9   I   r:    )g      g=ä࿩g      ?g6	t)迩g      gՁAڿg      ?gqXu)r   r/   r   r0   r1   )r   r,   Nr   r,   )r=   r>   )r   r   r?   r@   )r   finishr   r   Zanglesallr   r8   r   r   Ztips)r   Zsfr   r   r	   test_sankey2B   s*    

rC   Zpng)
extensionsc                 C   sZ   |   }t|g dg dd}|  |  }t|d}|jg dg dd |  d S )N)r   r/   r/   r   r0   r1   )r   r   r   r   r   r   )axr   r   )rE   r   )Zgcar   rA   r   )Zfig_testZfig_refZax_testZs_testZax_refZs_refr   r   r	   test_sankey3^   s    


rF   )r#   Znumpy.testingr   r   Zmatplotlib.sankeyr   Zmatplotlib.testing.decoratorsr   r
   r   r   markZparametrizer(   r.   rC   rF   r   r   r   r	   <module>   sT   











