o
    io                     @   s@  d dl mZ d dlZd dlmZ d dlmZ d dl	m
Z d dlmZ d dlmZ edgdddid	d
d Zedgddiddd Zedgddidddd Zedgddedddddd Zdd Zedgdddid	dd  Zed!gdddid	d"d# Zd$d% Zd&d' Zd(d) Zed*gd+gdddid,d-d. ZdS )/    )BytesION)image_comparison)FuncFormatterZbbox_inches_tightTbbox_inchestight)remove_textsavefig_kwargc               	   C   s  g dg dg dg dg dg} dgd  }}t | }tt |d }g }d	}tt |}td
d
\}}	t|D ]}
|	j|| |
 ||ddd || |
  }|dg q<t	g  t
dd tjdgd dd |jdgd ddd |  tj|||dd d S )N)iR iب i{% it i}  )iv  i i0 i ir )i/\ i: iS i= i5	 )iO2 i? iL i i )ia  i i|< iD i-      g333333?g?   edgeb)bottomaligncolorr   )g333333?皙?)loc)r   r   z
lower leftZbbox_to_anchorr   r   )ZcellTextZ	rowLabelsZ	colLabelsr   )lennparangeZzerospltsubplotsrangebarappendZxticksZxlimlegendreversetable)dataZ
col_labelsZ
row_labelsrowsindZ	cell_textwidthZyofffigaxrow r&   o/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/matplotlib/tests/test_bbox_tight.pytest_bbox_inches_tight   s2   


r(   Z bbox_inches_tight_suptile_legend)r   c                  C   s`   t jtddd t jddd t d t d d	d
 } t  j	t
|  t d d S )N
   za straight line)label)g?r   z
upper leftr   z
Axis titlezFigure titlec                 S   s   t | dkrdS t| S )N   zThe number 4)intstr)yposr&   r&   r'   y_formatter6   s   z:test_bbox_inches_tight_suptile_legend.<locals>.y_formatterzX axis)r   plotr   r   r   titlesuptitlegcayaxisZset_major_formatterr   Zxlabel)r0   r&   r&   r'   %test_bbox_inches_tight_suptile_legend-   s   

r6   z)bbox_inches_tight_suptile_non_default.png皙?)r   Ztolc                  C   s    t  \} }| jdddd d S )NZBooo      ?g?)xr.   )r   r   r3   r#   r$   r&   r&   r'   +test_bbox_inches_tight_suptitle_non_default@   s   r;   zbbox_inches_tight_layout.pngZmpl20layoutr   
pad_inches)r   styler   c                  C   s.   t jdd\} }|  jdd |d d S )NZconstrained)r<   r8   )Zh_padequal)r   r   Zget_layout_engineset
set_aspectr:   r&   r&   r'   )test_bbox_inches_tight_layout_constrainedH   s   rC   c                 C   s$   t  \}}|j| d ddd d S )Nzfoo.pngr   r<   r=   )r   r   savefig)Ztmp_pathr#   r$   r&   r&   r'   ,test_bbox_inches_tight_layout_notconstrainedQ   s   rE   Zbbox_inches_tight_clippingc                  C   s   t tdtd t  } | dd | dd tjddgdd| j	ddd}t
jd }| jd	9  _|j|| jd
 t  j| d S )Nr)   r   r
   id   bluer8   )	transformZ	facecoloralphag      ?)rH   )r   Zscatterr   r   r4   set_xlimZset_ylimmpatchesZ	RectangleZ	transDatampathPathZunit_regular_stardeepcopyZverticesZset_clip_pathZ	transAxesZgcfZartistsr   )r$   patchpathr&   r&   r'   test_bbox_inches_tight_clippingX   s   rQ   Zbbox_inches_tight_rasterc                  C   s"   t  \} }|jddgdd dS )z$Test rasterization with tight_layout      ?g       @TZ
rasterizedN)r   r   r1   r:   r&   r&   r'   test_bbox_inches_tight_rasterm   s   rT   c                  C   s@   t  \} }|jddtdfd |  | jt ddd d S )Nr	   r   nan)Zxyr   png)r   format)r   r   Zannotatefloatset_axis_offrD   r   r:   r&   r&   r'   test_only_on_non_finite_bboxu   s   rZ   c                  C   sn   t  \} }|tdd |jdd t }| j|dd |	d t 
|j\}}}||ks5J d S )Nr+   )   r[   )r   r7   )Zylimr   )r   r   )r   r   Z
pcolorfastr   r   reshaperA   r   rD   seekZimreadshape)r#   r$   bufheightr"   _r&   r&   r'   test_tight_pcolorfast}   s   
rb   c            	      C   s0  ddl m}  d\}}d}tjd||| || fd}t|g d}|| |  |jd |j	d t
|| ||}|j|dd	 |jt d
ddd t }|j|d
dd |d t
| |}|d d d d df dk s|J |d d d d d df dk rJ |jdksJ d S )Nr   )Image)r)      rF   F)ZframeondpiZfigsize)        rf   rR   rR   TrS   r   Zpdf)r   r>   rW   r=         )rd   r)   r+   )ZPILrc   r   ZfigureZAxesZadd_axesrY   ZxaxisZset_visibler5   r   r   r\   ZimshowrD   r   r]   Zasarrayopenallr^   )	rc   Zx_sizeZy_sizere   r#   r$   r   outZimr&   r&   r'   test_noop_tight_bbox   s&   

"&rl   Zbbox_inches_fixed_aspectrV   )
extensionsr   r   c                  C   sd   t ddi! t  \} }|ddg |dd |d W d    d S 1 s+w   Y  d S )Nzfigure.constrained_layout.useTr   r   r@   )r   Z
rc_contextr   r1   rJ   rB   r:   r&   r&   r'   test_bbox_inches_fixed_aspect   s   "rn   )ior   numpyr   Zmatplotlib.testing.decoratorsr   Zmatplotlib.pyplotZpyplotr   Zmatplotlib.pathrP   rL   Zmatplotlib.patchesZpatchesrK   Zmatplotlib.tickerr   r(   r6   r;   dictrC   rE   rQ   rT   rZ   rb   rl   rn   r&   r&   r&   r'   <module>   sR    







