o
    i<                     @   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   k/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/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sJ 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   sB   t jt|d tdi |  W d    d S 1 sw   Y  d S )Nmatchr   )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   sZ   t  }tjt|d |jddgd |jdi |  W d    d S 1 s&w   Y  d S )Nr!   r)   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s%J tdd	 |d jD s3J td
d	 |d jD sAJ |d j dksLJ t	|d j
g d t g ddgdgdd} |  }t|d jg d |d jg dks{J t	|d j
g d d S )N)r         п      ?      Foor   Bar)r   r   r   unitr   )r   r,   r   r,   c                 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   r5   )Nr3   r6   r7   r   r   r	   r:   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@   rA   )r   finishr   r   Zanglesallr   r9   r   r   Ztips)r   Zsfr   r   r	   test_sankey2B   s*   

rD   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   )rF   r   )Zgcar   rB   r   )Zfig_testZfig_refZax_testZs_testZax_refZs_refr   r   r	   test_sankey3^   s   


rG   )r#   Znumpy.testingr   r   Zmatplotlib.sankeyr   Zmatplotlib.testing.decoratorsr   r
   r   r   markZparametrizer(   r.   rD   rG   r   r   r   r	   <module>   sV    




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