3
$ßL]¯  ã               @   sˆ   d dl Z d dlZd dlZd dljZd dlmZ d dlZdd„ Z	dd„ Z
dd„ Zd	d
„ Zdd„ Zedgdd�dd„ ƒZdd„ Zdd„ ZdS )é    N)Úimage_comparisonc       
      C   sž   x˜t jt| ƒt| ƒttd||gƒƒƒD ]p\\}}\}}\}\}}	||krJq&t| d dj|ƒƒj||ƒ|	||f ks&td|||	||f rŠdnd|f ƒ‚q&W dS )z–
    x_shared and y_shared are n x n boolean matrices; entry (i, j) indicates
    whether the x (or y) axes of subplots i and j should be shared.
    Zxyr   z_shared_{}_axesz,axes %i and %i incorrectly %ssharing %s axisznot Ú N)Ú	itertoolsÚproductÚ	enumerateÚzipÚgetattrÚformatZjoinedÚAssertionError)
ÚaxsZx_sharedZy_sharedÚi1Zax1Úi2Zax2Zi3ÚnameZshared© r   úF/tmp/pip-install-edjban26/matplotlib/matplotlib/tests/test_subplots.pyÚcheck_shared   s    .r   c             C   sœ   dd„ }xŽt | ||ƒD ]~\}}}x8|jƒ |jƒ jg D ] }|jƒ |ks6td||ƒ ƒ‚q6W x8|jƒ |jƒ jg D ] }|jƒ |ksptd||ƒ ƒ‚qpW qW d S )Nc             S   s   | rdS dS )NZ	invisibleÚvisibler   )Úvr   r   r   Útostr   s    zcheck_visible.<locals>.tostrzX axis was incorrectly %szY axis was incorrectly %s)r   Zget_xticklabelsZ	get_xaxisZ
offsetTextZget_visibler
   Zget_yticklabelsZ	get_yaxis)r   Z	x_visibleZ	y_visibler   ÚaxZvxZvyÚlr   r   r   Úcheck_visible   s    r   c              C   sh  d} t j| d d… td�t j| d d… td�t jddddgddddgddddgddddggƒt jddddgddddgddddgddddggƒdœ}ddddgddddgdgd dgd dgd ddddgdœddddgdgd ddddgdgd dgd ddddgdœdœ}|d	 |d< |d
 |d< tjddƒ\}\\}}\}}||||g}t||d	 |d	 ƒ tj|ƒ ddd
d	ddg}	x†|	D ]~}
xv|	D ]n}tjdd|
|d�\}\\}}\}}||||g}t|||
 || ƒ t	||d |
 |d | ƒ tj|ƒ �qŠW �q€W tjddddd�\}\\}}\}}||||g}x|D ]}|j
ƒ  �q6W t	|ddddgddddgƒ d S )Né   é   )ZdtypeFT)ÚallÚnoneÚrowÚcol)r   r   r   r   FT)ÚxÚyr   r   r   r   )ÚsharexÚshareyr   r   )r   r   r   )ÚnumpyZonesÚboolÚzerosÚarrayÚpltÚsubplotsr   Úcloser   Zlabel_outer)ZrdimZsharer   ÚfÚa1Úa2Úa3Za4r   ÚopsZxoZyor   r   r   r   Útest_shared*   sX    












""
r.   c              C   s�   t jdddd�\} \}}t|gdgdgƒ |jjƒ  t|gdgdgƒ t jdddd�\} \}}t|gdgdgƒ |jjƒ  t|gdgdgƒ d S )Né   r   T)r!   F)r    )r&   r'   r   ZyaxisZ	tick_leftZxaxisZtick_bottom)r)   r*   r+   r   r   r   Útest_shared_and_movedg   s    

r0   c            .   C   sà   t jtƒ� tjdddd� W d Q R X t jtƒ� tjdddd� W d Q R X tjƒ �‚ tjddtd� t jtƒ� tjdddƒ W d Q R X t jtƒ� tjddd	ƒ W d Q R X t jtƒ� tjddd
ƒ W d Q R X W d Q R X d S )Nr   Zblah)r    )r!   Úignorez.*sharex argument to subplots)ÚmessageÚcategoryr/   r   é   éÿÿÿÿ)	ÚpytestZraisesÚ
ValueErrorr&   r'   ÚwarningsÚcatch_warningsÚfilterwarningsÚUserWarningr   r   r   r   Útest_exceptionsu   s    
r<   Zsubplots_offset_textF)Zbaseline_imagesZremove_textc              C   sz   t jdddƒ} t jdddƒd }tjdddd	d
�\}}|d j| | ƒ |d j| | ƒ |d j|| ƒ |d j|| ƒ d S )Nr   g    _ Bg    eÍÍAéd   é
   g     ˆÃ@r   r   r   )r    r!   r/   )r   r   )r/   r   )r   r/   )r/   r/   )r"   Zaranger&   r'   Zplot)r   r   ÚfigZaxesr   r   r   Útest_subplots_offsettext‰   s    r@   c              C   s(   t jƒ \} }|jƒ jƒ |jƒ ks$t‚d S )N)r&   r'   Zget_subplotspecZget_gridspecr
   )r?   r   r   r   r   Útest_get_gridspec”   s    rA   c              C   sR   ddi} dddgi}t jdd| |d�\}}| ddiks:t‚|dddgiksNt‚d S )Nr    r   Zwidth_ratiosr/   r   )Ú
subplot_kwÚgridspec_kw)r&   r'   r
   )rB   rC   r?   r   r   r   r   Útest_dont_mutate_kwargsš   s    
rD   )r   r8   r"   Zmatplotlib.pyplotZpyplotr&   Zmatplotlib.testing.decoratorsr   r6   r   r   r.   r0   r<   r@   rA   rD   r   r   r   r   Ú<module>   s   
=