a
    s=ic                     @   s\  d dl Z d dl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 d/d gdgd0d1fd.d d/d gdgd2d3ff	d4d5 Zd6d7 Zed8gd9d:d; ZdS )<    N)Sankey)check_figures_equalc                  C   s   t  } |   d S )N)r   add)sankey r   m/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/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ttd|d jsBJ |d jg dksXJ tdd	 |d jD stJ td
d	 |d jD sJ |d j	
 dksJ ttd|d jsJ t g ddgdgdd} |  }tttd|d jsJ |d jg dksJ ttd|d js<J 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*   r0   r   .0textr   r   r   
<listcomp>H       z test_sankey2.<locals>.<listcomp>c                 S   s    g | ]}|  d d dkqS )Nr1   r3   r4   r   r   r   r7   I   r8    )g      g=ä࿩g      ?g6	t)迩g      gՁAڿg      ?gqXu)r	   r-   r   r.   r/   )r   r*   Nr   r*   )r;   r<   )r   r   r=   r>   )r   finishnpallequalarrayr   Zanglesr   r6   r   ZallcloseZ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	   r.   r/   )r   r   r   r   r   r   )axr   r   )rF   r   )Zgcar   r?   r   )Zfig_testZfig_refZax_testZs_testZax_refZs_refr   r   r   test_sankey3^   s    


rG   )r!   numpyr@   Zmatplotlib.sankeyr   Zmatplotlib.testing.decoratorsr   r   r   r   markZparametrizer&   r,   rD   rG   r   r   r   r   <module>   sT   




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