U
    Fvf<                     @   sh  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dd dgddfddgdddg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d0d d1d"gdgd2d3fd0d d1d"gdgd4d5ff	d6d7 Zd8d9 Zed:g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   @/tmp/pip-unpacked-wheel-7vhvci0g/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s0td S )N      ?First)flowslabelsorientationsr   z
First
0.25r   Zdiagramstextsget_textAssertionError)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:t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   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 |  W 5 Q R X 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   s@   t  }tjt|d" |jddgd |jf |  W 5 Q R X 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   s8  t ddddgdgdgdd} |  }t|d	 jddddg |d	 jd
dd
dgksVttdd |d	 jD srttdd |d	 jD st|d	 j	 dkstt
|d	 jddddg t ddd	ddgdgdgdd} |  }t|d	 jddd	ddg |d	 jd
dd d
dgkstt
|d	 jdddddg d S )Nr         п      ?      Foor   Bar)r   r   r   unitr   r   r-   c                 S   s    g | ]}|  d d dkqS )r   r-   r3   r   .0textr   r   r	   
<listcomp>H   s     z test_sankey2.<locals>.<listcomp>c                 S   s    g | ]}|  d d dkqS )Nr4   r6   r7   r   r   r	   r:   I   s      )g      g=ä)g      ?g6	t))g      gՁAڿ)g      ?gqXu)r   r   )r   finishr   r   Zanglesr   allr   r9   r   r   Ztips)r   Zsfr   r   r	   test_sankey2B   s@     
 
r?   Zpng)
extensionsc              	   C   sz   |   }t|ddddddgddddddgd}|  |  }t|d	}|jddddddgddddddgd
 |  d S )Nr   r0   r1   r2   r   r   r   )axr   r   )rA   r   )Zgcar   r=   r   )Zfig_testZfig_refZax_testZs_testZax_refZs_refr   r   r	   test_sankey3^   s    
rB   )r$   Znumpy.testingr   r   Zmatplotlib.sankeyr   Zmatplotlib.testing.decoratorsr   r
   r   r   markZparametrizer)   r/   r?   rB   r   r   r   r	   <module>   sT   




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