U
    Fvf"                     @   s.  d dl Z d dlZd dlmZ d dlmZ d dlmZ	 dd Z
edgdd Zedgd	d
 Zdd Zedgde dkrd ndeddddd Zedgde dkrd ndeddddd Zedgddddd Zedgd de dkrd nd!d"d#d$ Zed%gd dd&d'd( Zd)d* ZdS )+    N)image_comparisonc              
   C   s*   | j ddd| fddt|dddd d S )	N       ?r   r      bk)
arrowstylefcec)ZxyZxytextsizeZ
arrowprops)Zannotatedict)axtr r   G/tmp/pip-unpacked-wheel-7vhvci0g/matplotlib/tests/test_arrow_patches.py
draw_arrow   s     r   Zfancyarrow_test_imagec            	      C   s   dddddg} ddt j g}tjt|t| dd	td
dd\}}t| D ]@\}}t|D ].\}}|||f }t||| |j	ddd q\qLd S )N皙?333333?皙?皙?r   ZfancysimpleF)   g      @   )Zaspect)ZsqueezefigsizeZ
subplot_kw)Z	labelleftZlabelbottom)
mpatches
ArrowStyleZFancypltsubplotslenr   	enumerater   Ztick_params)	r   r   figZaxsZi_rZr1Zi_tt1r   r   r   r   test_fancyarrow   s     
r$   zboxarrow_test_image.pngc                  C   s   t j } t| }d}|| d }tjd|d fd}d}tt| D ]<\}}|jd|| | d | |d||j	t
|dd	d
d qFd S )Ng333333?r   gUUUUUU@g      ?r   g5@centerwr   )Zboxstyler
   r   )Zhar   Z	transformZbbox)r   ZBoxStyle
get_stylesr    r   figurer!   sortedtextZtransFigurer   )stylesnspacingZ	figheightr"   Zfontsizei	stylenamer   r   r   test_boxarrow   s    
r1   c               	   C   sR   t jdddd} |  }|ddg |ddg |tjddd	d
dd | S )z
    Convenience function that prepares and returns a FancyArrowPatch. It aims
    at being used to test that the size of the arrow head does not depend on
    the DPI value of the exported picture.

    NB: this function *is not* a test in itself!
    Zfancyarrow_dpi_cor_test)      2   )r   dpir   r   )r   r   )皙?g333333?r3   ->d   )ZposAZposBZlwr	   mutation_scale)r   r)   Zadd_subplotset_xlimset_ylim	add_patchr   FancyArrowPatch)Zfig2r   r   r   r   !__prepare_fancyarrow_dpi_cor_test3   s     r>   zfancyarrow_dpi_cor_100dpi.pngTx86_64g{Gz?r8   )r5   )remove_texttolZsavefig_kwargc                   C   s
   t   dS )a   
    Check the export of a FancyArrowPatch @ 100 DPI. FancyArrowPatch is
    instantiated through a dedicated function because another similar test
    checks a similar export but with a different DPI value.

    Remark: test only a rasterized format.
    Nr>   r   r   r   r   test_fancyarrow_dpi_cor_100dpiE   s    rC   zfancyarrow_dpi_cor_200dpi.png   c                   C   s
   t   dS )z
    As test_fancyarrow_dpi_cor_100dpi, but exports @ 200 DPI. The relative size
    of the arrow head should be the same.
    NrB   r   r   r   r   test_fancyarrow_dpi_cor_200dpiT   s    	rE   zfancyarrow_dash.pngdefault)r@   stylec               
   C   sX   t  \} }tjddddddddd	}tjdddd
ddddd	}|| || d S )N)r   r   r   z-|>zangle3,angleA=0,angleB=90g      $@   Zdashedr   )r	   connectionstyler9   Z	linewidthZ	linestylecolorZangle3Zdotted)r   r   r   r=   r<   )r"   r   ee2r   r   r   test_fancyarrow_dash`   s&    
rM   zarrow_styles.pngZmpl20g{Gzt?)rG   r@   rA   c                  C   sB  t j } t| }tjdd\}}|dd |d| |jddddd t	t
| D ]D\}}t jd|d d	  |fd
|d d	  |f|dd}|| qXt	ddddgD ]\}}|}|d dkr|d7 }|d dkr|d7 }t	ddgD ]L\}}	|dt|	}
t jdd| | fdd| | f|
dd}|| qqd S )N)r   r   r%   r   r   )leftrightZbottomtopr   rH   g?g?   )r	   r9   z]-[z]-z-[z|-|-z,angleA=ANGLEz,angleB=ANGLEi<   ZANGLEg?g?)r   r   r(   r    r   r   r:   r;   Zsubplots_adjustr!   r*   r=   r<   replacestr)r,   r-   r"   r   r/   r0   patchrG   jZangler	   r   r   r   test_arrow_stylesu   s4    
 rY   zconnection_styles.png)rG   r@   c                  C   s~   t j } t| }tjdd\}}|dd |d| tt	| D ]2\}}t j
d|fd|d fd	|d
d}|| qFd S )N)   
   r%   r   r   rN   r   r6   r   r7   rR   )r	   rI   r9   )r   ConnectionStyler(   r    r   r   r:   r;   r!   r*   r=   r<   )r,   r-   r"   r   r/   r0   rW   r   r   r   test_connection_styles   s    
r]   c               	   C   sv   t jjddd} t jdd| d}tt t 	| W 5 Q R X t jjddd}t jdd|d}t 	| d S )N   rD   )ZangleAZangleB)r   r   r   )rI   gh@)
r   r\   ZAngle3r=   pytestZraises
ValueErrorr   Zgcar<   )Zconn_style_1p1Zconn_style_2p2r   r   r   test_invalid_intersection   s    rc   )r_   platformZmatplotlib.pyplotZpyplotr   Zmatplotlib.testing.decoratorsr   Zmatplotlib.patchesZpatchesr   r   r$   r1   r>   machiner   rC   rE   rM   rY   r]   rc   r   r   r   r   <module>   s:   



	



