o
    -h/                     @   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   R/var/www/vscode/kcb/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   data_updateunique_data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/   r0   r1   r%   )r   r.   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.   r2   r4   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)r5   r6   r7   rA   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)autousec                 C   s$   t  | _t  | _t| j| _d S r   )r   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   )	r<   testingassert_allclosere   convertrf   r@   rangelen)r   ri   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   )re   rl   r   rf   )r   rp   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/   r0   r1   re   rl   r   rf   )r   rs   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   )
re   axisinfor   rf   
isinstancemajlocr   StrCategoryLocator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!   )rv   re   default_unitsrf   r   r   r   r   r   r   test_default_unitss   s   "z+TestStrCategoryConverter.test_default_unitsN)r5   r6   r7   __doc__r8   r9   r   r   r<   infr=   r>   fvaluesr/   fixturerh   r:   r;   ro   rr   rt   r|   r   r   r   r   r   rB   A   s.    


	





rB   )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   rx   r   r<   rj   assert_array_equal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   rD   r   )
pltfiguresubplotsr<   rj   r   yaxismajorlocatorrm   r   r   rf   r   r   r   test_StrCategoryLocatorPlot   s   z2TestStrCategoryLocator.test_StrCategoryLocatorPlotN)
r5   r6   r7   r   r/   r:   r;   	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 )TestStrCategoryFormatterrC   )helloworldrq   r      Здравствуйте   приветydatar   c                 C   sP   t |}t |j}t|D ]\}}||||ksJ ||d |ks%J qd S r   )r   r   rz   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   rm   rn   r   r   r   	formatter)r   r   r   rf   r   r"   r   r   r   test_StrCategoryFormatterPlot   s
   z6TestStrCategoryFormatter.test_StrCategoryFormatterPlotN)r5   r6   r7   r8   r9   r   casesr/   r:   r;   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   r{   r   r   r      s    zaxis_test.<locals>.<listcomp>c                 S   s   g | ]}t j|qS r   )r   rz   _textr   lr   r   r   r      s    c                 S   s   g | ]}|qS r   r   r   r   r   r   r      s    )r   rm   rn   r<   rj   r   get_majorticklocsr@   r   r   r   )r{   r   r   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 listrD   
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   r<   arrayr   xaxis)r   r   r   rf   countsr   r   r   test_plot_bytes      zTestPlotBytes.test_plot_bytesN)r5   r6   r7   r<   r   bytes_casesr9   	bytes_ids
bytes_datar/   r:   r;   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   )rF   113zstring ndarrayr   )   1s   11   3r   r   r   ndatac                 C   r   r   r   )r   r   r   rf   r   r   r   r   test_plot_numlike   r   z!TestPlotNumlike.test_plot_numlikeN)r5   r6   r7   r<   r   numlike_casesr9   numlike_idsnumlike_datar/   r:   r;   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   rf   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   happyr   )r   r   r   )Pythonisfun)r   r   r   )xxyyyxr~   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   rf   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#   rE   r"   )r   r$   r"   )r!   r#   r"   rE   )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   r   r   r   r   r   r   )r   rf   r   r   r   %test_update_plot_heterogenous_plotter   s   z3TestPlotTypes.test_update_plot_heterogenous_plotterr	   r
   r+   znumber integerrF   r   r`   ra   rb   missing12)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/   r0   r1   r   r   r   rf   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) r5   r6   r7   r/   r:   r;   r   r   r   r   r   usefixturesr   r   r   r   r   r<   r,   r=   r9   r>   r   r   r   r   paramr   xfailplottersr   r   r   r   r   r   r      s@    








r   default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   )xunitsyunitsV1V2)r   r   r9   dictr   r   r@   r   )fig_testfig_refr   t0t1t2t3ax_testax_refrf   kwargsx_units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   update_unitsr   r   rf   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!   rE   ff)r   )
g       @        r        ?r  r  r  r  r  r  )r   r   histshaper<   rj   rk   )figrf   nbins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#   rE   r"   )r   r   r   r   r#   rE   )r   r   r   warningscatch_warningsset_xlimr  r   r   r   test_set_limD  s
   
"r  )%r   r  r/   numpyr<   
matplotlibmplmatplotlib.axesr   matplotlib.pyplotpyplotr   matplotlib.categorycategoryr   matplotlib.testing.decoratorsr   r   r?   rB   r   r   r   r   r   r   r   r   r   r   r   stylecontextr	  r  r  r  r   r   r   r   <module>   s4    .6

P
	