o
    e%                     @   s   d dl Zd dlZd dlmZ d dlZd dlm	Z	 d dl
mZmZ d dlmZmZ d dlmZ dd Zedgd	d
dd Zedgdd Zedgd	d
dd Zdd Zedgdd Zdd Zedgddd ZdS )    N)Path)
CustomCellTable)image_comparisoncheck_figures_equal)Bboxc                  C   s   ddg} t j| d d S )Nbr)cellColours)plttable)
cellcolors r   J/var/www/myenv/lib/python3.10/site-packages/matplotlib/tests/test_table.pytest_non_square   s   r   ztable_zorder.pngT)remove_textc                  C   s   ddgddgg} d}dd dD }g }t t|}t| D ]}||7 }|d	d |D  qt d
dt j d}tj|t 	|ddd tj
|||ddd tj
|||ddd tg  d S )NiR iب iv  i )FreezeWindc                 S   s   g | ]}d | qS )z%d yearr   .0xr   r   r   
<listcomp>   s    ztest_zorder.<locals>.<listcomp>)d   2   c                 S   s   g | ]}d |d  qS )z%1.1fg     @@r   r   r   r   r   r      s    r      r      )lwzordercenter)cellText	rowLabels	colLabelslocr   zupper center)npzeroslenreversedappendlinspacepir   plotcosr   yticks)datar"   r!   r    yoffrowtr   r   r   test_zorder   s2   r2   ztable_labels.pngc            	      C   s   d} t dd| }tj|}dg|  g|  }t }|ddd}|d |j||dd |ddd	}|d |j||d
g|  dd |ddd}|d |j||dd |ddd}|d |j||d
g|  dd d S )N   r      1r   offbest)r    
rowColoursr#   r   Header)r    r8   r!   r#   )r    
colColoursr#   )r    r:   r"   r#   )	r$   r)   r   cmRdYlGnfigureadd_subplotaxisr   )	dimccoloursr    figax1ax2ax3ax4r   r   r   test_label_colours3   s>   




rH   ztable_cell_manipulation.pngc                  C   s   d} dgt |  gd }dgt |  }tjt | dt | d fd\}}t|| D ]\}}|j||d|d	 |d
 q)t  d S )N
horizontalverticalopenclosedTRBLr5   r   皙?r   r4   )nrowsfigsizer   )	colWidthsr    r#   edgesr6   )r&   r   subplotszipr   r?   tight_layout)cellsr    rU   _axsaxcellr   r   r   test_diff_cell_tableX   s   "r_   c                  C   s  d} t jt jt jt jt jft jt jt jt jt jft jt jt jt jt jft jt jt jt jt jft jt jt jt jt jft jt jt jt jt jft jt jt jt jt jft jt jt jt jt jff}t| |D ]\}}td|ddd}tdd |  D }||ksJ qad S )NrI   r   r   r4   )visible_edgeswidthheightc                 s   s    | ]\}}|V  qd S )Nr   )r   r[   sr   r   r   	<genexpr>y   s    z"test_customcell.<locals>.<genexpr>)	r   MOVETOLINETO	CLOSEPOLYrX   r   tupleget_pathiter_segments)typescodesr1   rA   r^   coder   r   r   test_customcellj   s   ro   ztable_auto_column.pngc            	      C   s  t  } | ddd}|d |jddgddggddgd	d
gdd}|d |d |g d | ddd}|d |jddgddggddgd	d
gdd}|d |d |d | ddd}|d |jddgddggddgd	d
gdd}|d |d |d |d |d | ddd}|d |jddgddggddgd	d
gdd}|d |d tj	t
jdd |d W d    n1 sw   Y  tj	t
jdd |dg W d    d S 1 sw   Y  d S )Nr   r4   r6   zFit Textr   z-very long long text, Longer text than defaultArP   Col1Col2r   )r    r!   r"   r#   F   )r   r4   r3   rt   r   z('col' must be an int or sequence of ints)matchz-101)r   r=   r>   r?   r   auto_set_font_sizeset_fontsizeauto_set_column_widthpytestwarnsmplMatplotlibDeprecationWarning)	rC   rD   tb1rE   tb2rF   tb3rG   tb4r   r   r   test_auto_column}   s   















"r   c                  C   s   t  \} }t|}|dddd}t|tsJ ||d u s!J tdddd d}||d< |d |u s5J |  t | d S )Nr4   r   )r4   r   r`   )ra   )r   r4   )r   rW   r   add_cell
isinstancer   
propertiessetp)rC   r]   r   r^   cell2r   r   r   test_table_cells   s   r   png)
extensionsc                 C   sr   ddgddgg}d}d}dd |D }|   }|j|||d	g d
d |  }|j|||d	tddddd d S )Nr   r3   r      )FooBar)AdaBobc                 S   s   g | ]	}d d |D qS )c                 S   s   g | ]}| qS r   r   r   r   r   r   r      s    z.test_table_bbox.<locals>.<listcomp>.<listcomp>r   )r   r0   r   r   r   r      s    z#test_table_bbox.<locals>.<listcomp>r   )rR   皙?皙?g333333?)r    r!   r"   r#   bboxrR   r   g?r   )rW   r   r   from_extents)fig_testfig_refr.   
col_labels
row_labels	cell_textax_listax_bboxr   r   r   test_table_bbox   s(   
r   )numpyr$   ry   matplotlib.pyplotpyplotr   
matplotlibr{   matplotlib.pathr   matplotlib.tabler   r   matplotlib.testing.decoratorsr   r   matplotlib.transformsr   r   r2   rH   r_   ro   r   r   r   r   r   r   r   <module>   s*    
 
$

?
