o
    îÇhª  ã                   @   sZ  d dl mZ 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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e ¡ dkrHd nd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 )0é    )ÚBytesION)Úimage_comparison)ÚFuncFormatterÚ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ÓÐ iÝ0 iìƒ iÆr )i/\ i¨: iîS i=™ i5	 )iO2 iÂ? i€L iïò i )ia  iõ i|< iDì i-Ì  Ú é   g333333Ó?gš™™™™™Ù?é   ÚedgeÚb)ÚbottomÚalignÚcolorr   )g333333ó?çš™™™™™É?)Úloc)r   r   z
lower left©Úbbox_to_anchorr   r   )ÚcellTextÚ	rowLabelsÚ	colLabelsr   )ÚlenÚnpÚarangeÚzerosÚpltÚsubplotsÚrangeÚbarÚappendÚxticksÚxlimÚlegendÚreverseÚtable)ÚdataÚ
col_labelsÚ
row_labelsÚrowsÚindÚ	cell_textÚwidthÚyoffÚfigÚaxÚrow© r2   út/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/matplotlib/tests/test_bbox_tight.pyÚtest_bbox_inches_tight   s2   ü


ÿr4   Ú bbox_inches_tight_suptile_legendÚx86_64g{®Gáz”?)r	   Útolc                  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Úposr2   r2   r3   Úy_formatter8   s   z:test_bbox_inches_tight_suptile_legend.<locals>.y_formatterzX axis)r   Úplotr   r   r$   ÚtitleÚsuptitleÚgcaÚyaxisÚset_major_formatterr   Úxlabel)r?   r2   r2   r3   Ú%test_bbox_inches_tight_suptile_legend.   s   

rG   z)bbox_inches_tight_suptile_non_default.pngçš™™™™™¹?c                  C   s    t  ¡ \} }| jdddd d S )NÚBoooç      à?gš™™™™™ñ?)Úxr=   )r   r   rB   ©r/   r0   r2   r2   r3   Ú+test_bbox_inches_tight_suptitle_non_defaultB   s   rM   zbbox_inches_tight_layout.pngÚmpl20Úlayout©r   Ú
pad_inches)r   Ústyler	   c                  C   s.   t jdd\} }|  ¡ jdd | d¡ d S )NÚconstrained)rO   rJ   )Úh_padÚequal)r   r   Úget_layout_engineÚsetÚ
set_aspectrL   r2   r2   r3   Ú)test_bbox_inches_tight_layout_constrainedJ   s   rY   c                 C   s$   t  ¡ \}}|j| d ddd d S )Nzfoo.pngr   rO   rP   )r   r   Úsavefig)Útmp_pathr/   r0   r2   r2   r3   Ú,test_bbox_inches_tight_layout_notconstrainedS   s   r\   Ú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 )Nr8   r   r   iÎÿÿÿéd   ÚbluerJ   )Ú	transformÚ	facecolorÚalphag      Ð?)r`   )r   Úscatterr   r   rC   Úset_xlimÚset_ylimÚmpatchesÚ	RectangleÚ	transDataÚmpathÚPathÚunit_regular_starÚdeepcopyÚverticesÚset_clip_pathÚ	transAxesÚgcfÚartistsr!   )r0   ÚpatchÚpathr2   r2   r3   Útest_bbox_inches_tight_clippingZ   s   þrt   Úbbox_inches_tight_rasterc                  C   s"   t  ¡ \} }|jddgdd dS )z$Test rasterization with tight_layoutg      ð?g       @T©Ú
rasterizedN)r   r   r@   rL   r2   r2   r3   Útest_bbox_inches_tight_rastero   s   rx   c                  C   s@   t  ¡ \} }|jddtdƒfd | ¡  | jtƒ ddd d S )Nr
   r   Únan)Úxyr   Úpng)r   Úformat)r   r   ÚannotateÚfloatÚset_axis_offrZ   r   rL   r2   r2   r3   Útest_only_on_non_finite_bboxw   s   r€   c                  C   sn   t  ¡ \} }| t d¡ d¡¡ |jdd tƒ }| j|dd | 	d¡ t  
|¡j\}}}||ks5J ‚d S )Nr:   )é   r   )r   rH   )Úylimr   )r   r   )r   r   Ú
pcolorfastr   r   ÚreshaperW   r   rZ   ÚseekÚimreadÚshape)r/   r0   ÚbufÚheightr-   Ú_r2   r2   r3   Útest_tight_pcolorfast   s   
r‹   c            	      C   s   ddl m}  d\}}d}tjd||| || fd}| 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 ¡ stJ ‚|d d …d d …d d…f dk ¡ r‡J ‚|jdksŽJ ‚d S )Nr   )ÚImage)r8   é   r^   F)ÚframeonÚdpiÚfigsize)r   r   r   r   Trv   r   Úpdf)r   rQ   r|   rP   é   éÿ   )r   r8   r:   )ÚPILrŒ   r   ÚfigureÚadd_axesr   ÚxaxisÚset_visiblerD   r   r   r„   ÚimshowrZ   r   r…   ÚasarrayÚopenÚallr‡   )	rŒ   Úx_sizeÚy_sizer   r/   r0   r'   ÚoutÚimr2   r2   r3   Útest_noop_tight_bboxŒ   s$   

"&r¡   Úbbox_inches_fixed_aspectr{   )Ú
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   rU   )r   Ú
rc_contextr   r@   rd   rX   rL   r2   r2   r3   Útest_bbox_inches_fixed_aspect¨   s   "ür¥   )Úior   ÚplatformÚnumpyr   Úmatplotlib.testing.decoratorsr   Úmatplotlib.pyplotÚpyplotr   Úmatplotlib.pathrs   ri   Úmatplotlib.patchesÚpatchesrf   Úmatplotlib.tickerr   r4   ÚmachinerG   rM   ÚdictrY   r\   rt   rx   r€   r‹   r¡   r¥   r2   r2   r2   r3   Ú<module>   sV    ÿ
þ
þ

þ
ÿ
ÿ

ÿ