o
    j/                     @   s   d Z ddlZddl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 G dd dZG dd dZG d	d
 d
ZejejejgZg dZG dd dZG dd dZdd ZG dd dZG dd dZG dd dZej dedgddd Z!dd Z"dd  Z#d!d" Z$dS )#z#Catch all for categorical functions    N)Axes)check_figures_equalc                   @   s   e Zd Zddgdgffddgdgffdg dg dffgZee \ZZejj	d	eed
dd Z
dd ZddejfdddgfdddgfgZee \ZZejj	deed
dd Zejj	deed
dd ZdS )TestUnitDatasinglehello worldr   unicode   Здравствуйте мирmixed)Aznp.nanBz3.14   мир)r               z
data, locsidsc                 C   s:   t |}t|j |ksJ t|j |ksJ d S N)catUnitDatalist_mappingkeysvalues)selfdatalocsunit r   _/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/matplotlib/tests/test_category.py	test_unit   s   
zTestUnitData.test_unitc                 C   s   ddg}ddg}g d}g d}g d}t |}t|j |ks$J t|j |ks/J || t|j |ks?J t|j |ksJJ d S )Nadr   r   )br"   e)r!   r"   r#   r$   )r   r   r   r   )r   r   r   r   r   r   update)r   r   r   Zdata_updateZunique_dataZupdated_locsr   r   r   r   test_update   s   

zTestUnitData.test_update)numberQ	@nanr   r(      z
mixed typer
   r   fdatac                 C   s:   t t t| W d    d S 1 sw   Y  d S r   )pytestraises	TypeErrorr   r   )r   r+   r   r   r   test_non_string_fails0   s   "z"TestUnitData.test_non_string_failsc                 C   sB   t  }tt || W d    d S 1 sw   Y  d S r   )r   r   r,   r-   r.   r%   )r   r+   Zunitdatar   r   r   test_non_string_update_fails5   s   "z)TestUnitData.test_non_string_update_failsN)__name__
__module____qualname__
test_caseszipr   r   r,   markparametrizer    r&   npr)   failing_test_casesfidsr+   r/   r0   r   r   r   r   r      s&    


r   c                   @   s   e Zd Zdd ZdS )FakeAxisc                 C   s
   || _ d S r   )units)r   r<   r   r   r   __init__=   s   
zFakeAxis.__init__N)r1   r2   r3   r=   r   r   r   r   r;   <   s    r;   c                   @   s   e Zd ZdZddgfddgfdg dfdd	d
gfdg dfgZee \ZZdddej	gfdddgfgZ
ee
 \ZZejdddd Zejjdeeddd Zejjdddgddgddd Zejjd eedd!d" Zd#d$ Zd%d& Zd'S )(TestStrCategoryConverterz
    Based on the pandas conversion and factorization tests:

    ref: /pandas/tseries/tests/test_converter.py
         /pandas/tests/test_algos.py:TestFactorize
    r   r   asciir   r   r!   r#   czinteger string12zsingle + values>10)r
   r   CDEFGHIJKLMNOPQRSTUVWXYZr	   r(   r
   string integer42*   T)Zautousec                 C   s$   t  | _t  | _t| j| _d S r   )r   ZStrCategoryConverterccr   r   r;   ax)r   requestr   r   r   	mock_axisX   s   

z"TestStrCategoryConverter.mock_axisvalsr   c                 C   s,   t j| j|| jj| jtt| d S r   )	r8   testingassert_allcloser_   convertr`   r<   rangelen)r   rc   r   r   r   test_convert_   s
   
z%TestStrCategoryConverter.test_convertvaluehir   c                 C   s    | j || j| jdksJ d S )Nr   )r_   rf   r   r`   )r   rj   r   r   r   test_convert_one_stringe   s    z0TestStrCategoryConverter.test_convert_one_stringfvalsc                 C   sD   t t | j|| j| j W d    d S 1 sw   Y  d S r   )r,   r-   r.   r_   rf   r   r`   )r   rm   r   r   r   test_convert_faili   s   "z*TestStrCategoryConverter.test_convert_failc                 C   s:   | j | j| j}t|jtjsJ t|jtj	sJ d S r   )
r_   Zaxisinfor   r`   
isinstanceZmajlocr   StrCategoryLocatorZmajfmtStrCategoryFormatter)r   axisr   r   r   test_axisinfon   s   z&TestStrCategoryConverter.test_axisinfoc                 C   s"   t | jdg| jtjsJ d S )Nr!   )ro   r_   Zdefault_unitsr`   r   r   r   r   r   r   test_default_unitss   s   "z+TestStrCategoryConverter.test_default_unitsN)r1   r2   r3   __doc__r4   r5   r   r   r8   infr9   r:   fvaluesr,   fixturerb   r6   r7   ri   rl   rn   rs   ru   r   r   r   r   r>   A   s.    


	





r>   )scatterplotbarc                   @   s.   e Zd Zdd Zejjdeeddd Z	dS )TestStrCategoryLocatorc                 C   sB   g d}t dd |D }t |j}tj|d d | d S )N)r   r   r   r   r               	   
   c                 S   s   g | ]}t |qS r   )str).0jr   r   r   
<listcomp>~   s    zBTestStrCategoryLocator.test_StrCategoryLocator.<locals>.<listcomp>)r   r   rp   r   r8   rd   assert_array_equalZtick_values)r   r   r   ticksr   r   r   test_StrCategoryLocator|   s   z.TestStrCategoryLocator.test_StrCategoryLocatorplotterr   c                 C   s>   t   }||g dg d tj|jj t	d d S )N)r   r   r   r@   r   )
pltfiguresubplotsr8   rd   r   yaxismajorZlocatorrg   r   r   r`   r   r   r   test_StrCategoryLocatorPlot   s   z2TestStrCategoryLocator.test_StrCategoryLocatorPlotN)
r1   r2   r3   r   r,   r6   r7   	PLOT_LISTPLOT_IDSr   r   r   r   r   r}   {   s    r}   c                   @   sv   e Zd Zdg dfdddgfgZee \ZZejj	deeddd	 Z
ejj	deedejj	d
eeddd ZdS )TestStrCategoryFormatterr?   )helloworldrk   r      Здравствуйте   приветydatar   c                 C   sP   t |}t |j}t|D ]\}}||||ksJ ||d |ks%J qd S r   )r   r   rq   r   	enumerate)r   r   r   labelsir"   r   r   r   test_StrCategoryFormatter   s   
z2TestStrCategoryFormatter.test_StrCategoryFormatterr   c                 C   sf   t   }||tt|| t|D ]\}}|jj||ks#J q|jj|d dks1J d S )Nr    )	r   r   r   rg   rh   r   r   r   	formatter)r   r   r   r`   r   r"   r   r   r   test_StrCategoryFormatterPlot   s
   z6TestStrCategoryFormatter.test_StrCategoryFormatterPlotN)r1   r2   r3   r4   r5   r   casesr,   r6   r7   r   r   r   r   r   r   r   r   r      s    


r   c                    s   t tt|}tj  |  fdd|D }|dd |D ks%J t  jj	 dd |D ks6J t  jj
 |ksBJ d S )Nc                    s   g | ]	} j ||qS r   )r   r   )r   r   rr   r   r   r      s    zaxis_test.<locals>.<listcomp>c                 S   s   g | ]}t j|qS r   )r   rq   _textr   lr   r   r   r      s    c                 S   s   g | ]}|qS r   r   r   r   r   r   r      s    )r   rg   rh   r8   rd   r   Zget_majorticklocsr<   r   r   r   )rr   r   r   Zgraph_labelsr   r   r   	axis_test   s   "r   c                   @   sl   e Zd Zdg dfdg dfdeg dfgZee \ZZe	j
jdeede	j
jdeedd	d
 ZdS )TestPlotBytesstring listr@   
bytes list)   a   b   cbytes ndarrayr   r   bdatac                 C   6   t   }tg d}|||| t|j| d S N)r   r   r~   r   r   r   r8   arrayr   xaxis)r   r   r   r`   countsr   r   r   test_plot_bytes      zTestPlotBytes.test_plot_bytesN)r1   r2   r3   r8   r   Zbytes_casesr5   Z	bytes_ids
bytes_datar,   r6   r7   r   r   r   r   r   r   r   r      s    

r   c                   @   s|   e Zd Zdg dfdeg dfdg dfdeg dfgZee \ZZe	j
jdeede	j
jd	eedd
d ZdS )TestPlotNumliker   )rB   Z113zstring ndarrayr   )   1s   11   3r   r   r   ndatac                 C   r   r   r   )r   r   r   r`   r   r   r   r   test_plot_numlike   r   z!TestPlotNumlike.test_plot_numlikeN)r1   r2   r3   r8   r   Znumlike_casesr5   Znumlike_idsZnumlike_datar,   r6   r7   r   r   r   r   r   r   r   r      s    

r   c                   @   sp  e Zd Zejjdeeddd Zej	dd Z
ejdejjdeeddd	 Zejdejjdeedd
d Zejdejjdeeddd Zejjdeeddd Zdd ZdddgfdddgfdddgfddejgfgZee \ZZejejejejejjdgZejdeejjdeeddd  Zejdeejjdeedd!d" Zd#S )$TestPlotTypesr   r   c                 C   s4   t   }ddg}|||ddg t|j| d S )Nr   r   r   r   )r   r   r   r   r   )r   r   r`   wordsr   r   r   test_plot_unicode   s   zTestPlotTypes.test_plot_unicodec                 C   s,   g d| _ g d| _g d| _g d| _d S )N)r   Zhappyr   )r   r   r   )PythonisZfun)r   r   r~   )xxyyyxrt   r   r   r   	test_data   s   


zTestPlotTypes.test_datar   c                 C   s.   t   }||| j| j t|j| j d S r   )r   r   r   r   r   r   r   r   r   r   r`   r   r   r   test_plot_xaxis      zTestPlotTypes.test_plot_xaxisc                 C   s.   t   }||| j| j t|j| j d S r   )r   r   r   r   r   r   r   r   r   r   r   test_plot_yaxis   r   zTestPlotTypes.test_plot_yaxisc                 C   s<   t   }||| j| j t|j| j t|j| j d S r   )r   r   r   r   r   r   r   r   r   r   r   r   test_plot_xyaxis   s   zTestPlotTypes.test_plot_xyaxisc                 C   sl   t   }||ddgddg ||g dg d ||g dg d t|jg d	 t|jg d
 d S Nr!   r#   r$   g)r!   r#   r"   )fr!   r#   )r#   rA   r"   )r   r$   r"   )r!   r#   r"   rA   )r$   r   r   r!   r#   r"   )r   r   r   r   r   r   r   r   r   r   test_update_plot   s   zTestPlotTypes.test_update_plotc                 C   sl   t   }|ddgddg |g dg d |g dg d t|jg d	 t|jg d
 d S r   )	r   r   r   rz   r{   r|   r   r   r   )r   r`   r   r   r   %test_update_plot_heterogenous_plotter   s   z3TestPlotTypes.test_update_plot_heterogenous_plotterr	   r
   r(   znumber integerrB   r   r\   r]   r^   missingZ12)Zmarksxdatac                 C   sL   t   }tt |||ddg W d    d S 1 sw   Y  d S )Nr   r   r   r   r   r,   r-   r.   r   r   r   r`   r   r   r   test_mixed_type_exception  s   "z'TestPlotTypes.test_mixed_type_exceptionc                 C   s`   t   }tt ||ddgddg |||ddg W d    d S 1 s)w   Y  d S )Nr   r   r   r   r   r   r   r   r    test_mixed_type_update_exception  s
   "z.TestPlotTypes.test_mixed_type_update_exceptionN) r1   r2   r3   r,   r6   r7   r   r   r   ry   r   Zusefixturesr   r   r   r   r   r8   r)   r9   r5   r:   rx   r   rz   r|   paramr{   ZxfailZplottersr   r   r   r   r   r   r      s@    








r   defaultZpng)
extensionsc                 C   s   ddl m } |ddd}|ddd}|ddd}|ddd}|  }| }t||gi td d dfD ]8\}	}
|	j||gd	d
gfi |
 |	jj}|	jj}|	j||gd	d
gfi |
 ||	jju scJ ||	jju skJ q3d S )Nr   )datetimei  r   r   r   r   )ZxunitsZyunitsZV1ZV2)r   r   r5   dictr{   r   r<   r   )Zfig_testZfig_refr   t0t1t2Zt3Zax_testZax_refr`   kwargsZx_unitsZy_unitsr   r   r   test_overriding_units_in_plot  s"   r   c                  C   s,   t  \} }|jddg |g g  dS )zQ
    Smoke test to check that no deprecation warning is emitted. See #22640.
    r!   r#   N)r   r   r   Zupdate_unitsr{   r   r`   r   r   r   !test_no_deprecation_on_empty_data4  s   r   c                  C   sD   t  \} }|g d\}}}|jdksJ tj|g d d S )N)r!   r#   r!   rA   ff)r   )
g       @        r         ?r   r   r   r   r   r   )r   r   histshaper8   rd   re   )Zfigr`   nZbinsZpatchesr   r   r   	test_hist=  s   r   c                  C   sZ   t  \} }|g dg d t  |dd W d    d S 1 s&w   Y  d S )N)r!   r#   rA   r"   )r   r   r   r   r#   rA   )r   r   r{   warningscatch_warningsZset_xlimr   r   r   r   test_set_limD  s
   
"r   )%rv   r   r,   numpyr8   Z
matplotlibZmplZmatplotlib.axesr   Zmatplotlib.pyplotZpyplotr   Zmatplotlib.categorycategoryr   Zmatplotlib.testing.decoratorsr   r   r;   r>   rz   r{   r|   r   r   r}   r   r   r   r   r   stylecontextr   r   r   r   r   r   r   r   <module>   s4    .6

P
	