o
    i'                     @   s   d Z ddlZddl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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dd ZdS )z#Catch all for categorical functions    N)Axesc                   @   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   Y/var/www/edux/Edux_v2/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   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_fails,   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/   r0   r$   )r   r-   unitdatar   r   r   test_non_string_update_fails1   s   "z)TestUnitData.test_non_string_update_failsN)__name__
__module____qualname__
test_caseszipr   r   r.   markparametrizer   r(   npr+   failing_test_casesfidsr-   r1   r3   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__9   s   
zFakeAxis.__init__N)r4   r5   r6   r@   r   r   r   r   r>   8   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d d! Z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_axisT   s   

z"TestStrCategoryConverter.mock_axisvalsr   c                 C   s,   t j| j|| jj| jtt| d S r   )	r;   testingassert_allcloserd   convertre   r?   rangelen)r   rh   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   )rd   rk   r   re   )r   ro   r   r   r   test_convert_one_stringa   s    z0TestStrCategoryConverter.test_convert_one_stringc                 C   s.   | j d| j| j}tj|tdg d S )N        )rd   rk   r   re   r;   ri   rj   array)r   actualr   r   r   test_convert_one_numbere   s   z0TestStrCategoryConverter.test_convert_one_numberc                 C   sB   t jg dtd}| j|| j| j}t j|t g d d S )N)r   r   r   )dtype)      ?       @g      @)	r;   rs   floatrd   rk   r   re   ri   rj   )r   r   rt   r   r   r   test_convert_float_arrayi   s   z1TestStrCategoryConverter.test_convert_float_arrayfvalsc                 C   sD   t t | j|| j| j W d    d S 1 sw   Y  d S r   )r.   r/   r0   rd   rk   r   re   )r   r{   r   r   r   test_convert_failn   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   )
rd   axisinfor   re   
isinstancemajlocr   StrCategoryLocatormajfmtStrCategoryFormatter)r   axisr   r   r   test_axisinfos   s   z&TestStrCategoryConverter.test_axisinfoc                 C   s"   t | jdg| jtjsJ d S )Nr    )r~   rd   default_unitsre   r   r   r   r   r   r   test_default_unitsx   s   "z+TestStrCategoryConverter.test_default_unitsN)r4   r5   r6   __doc__r7   r8   r   r   r;   infr<   r=   fvaluesr.   fixturerg   r9   r:   rn   rq   ru   rz   r|   r   r   r   r   r   r   rA   =   s2    


	





rA   c                   C   s   t   S r   )pltfiguresubplotsr   r   r   r   re   |   s   re   )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   r   r   r;   ri   assert_array_equaltick_values)r   r   r   ticksr   r   r   test_StrCategoryLocator   s   z.TestStrCategoryLocator.test_StrCategoryLocatorplotterr   c                 C   s,   | g d tj|jj td d S )NrC   r   )r   r;   ri   r   yaxismajorlocatorrl   r   re   r   r   r   r   test_StrCategoryLocatorPlot   s   z2TestStrCategoryLocator.test_StrCategoryLocatorPlotN)
r4   r5   r6   r   r.   r9   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 )TestStrCategoryFormatterrB   )helloworldrp   r      Здравствуйте   приветydatar   c                 C   sP   t |}t |j}t|D ]\}}||||ksJ ||d |ks%J qd S r   )r   r   r   r   	enumerate)r   re   r   r   labelsir!   r   r   r   test_StrCategoryFormatter   s   
z2TestStrCategoryFormatter.test_StrCategoryFormatterr   c                 C   sZ   ||t t|| t|D ]\}}|jj||ksJ q|jj|d dks+J d S )Nr    )rl   rm   r   r   r   	formatter)r   re   r   r   r   r!   r   r   r   test_StrCategoryFormatterPlot   s   z6TestStrCategoryFormatter.test_StrCategoryFormatterPlotN)r4   r5   r6   r7   r8   r   casesr.   r9   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   r   _textr   lr   r   r   r      s    c                 S   s   g | ]}|qS r   r   r   r   r   r   r      s    )r   rl   rm   r;   ri   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 listrC   
bytes list)   a   b   cbytes ndarrayr   r   bdatac                 C   *   t g d}|||| t|j| d S N)r   r   r   r;   rs   r   xaxis)r   re   r   r   countsr   r   r   test_plot_bytes      zTestPlotBytes.test_plot_bytesN)r4   r5   r6   r;   rs   bytes_casesr8   	bytes_ids
bytes_datar.   r9   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   )rE   113zstring ndarrayr   )   1s   11   3r   r   r   ndatac                 C   r   r   r   )r   re   r   r   r   r   r   r   test_plot_numlike   r   z!TestPlotNumlike.test_plot_numlikeN)r4   r5   r6   r;   rs   numlike_casesr8   numlike_idsnumlike_datar.   r9   r:   r   r   r   r   r   r   r   r      s    

r   c                   @   sh  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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   s(   ddg}|||ddg t |j| d S )Nr   r   r   r   )r   r   )r   re   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   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"   ||| j | j t|j| j  d S r   )r   r   r   r   r   re   r   r   r   r   r   test_plot_xaxis      zTestPlotTypes.test_plot_xaxisc                 C   s"   ||| j | j t|j| j d S r   )r   r   r   r   r   r   r   r   test_plot_yaxis   r   zTestPlotTypes.test_plot_yaxisc                 C   s0   ||| j | j t|j| j  t|j| j d S r   )r   r   r   r   r   r   r   r   r   test_plot_xyaxis   s   zTestPlotTypes.test_plot_xyaxisc                 C   s`   ||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"   rD   r!   )r   r#   r!   )r    r"   r!   rD   )r#   r   r   r    r"   r!   )r   r   r   r   r   r   r   test_update_plot   s
   zTestPlotTypes.test_update_plotr   r	   r*   znumber integerrE   r   r_   r`   ra   missing12)marksxdatac                 C   s@   t t |||ddg W d    d S 1 sw   Y  d S )Nr   r   r.   r/   r0   r   re   r   r   r   r   r   test_mixed_type_exception  s   "z'TestPlotTypes.test_mixed_type_exceptionc                 C   sT   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)r4   r5   r6   r.   r9   r:   r   r   r   r   r   usefixturesr   r   r   r   r;   r+   r<   r8   r=   r   r   r   r   paramr   xfailplottersr   r   r   r   r   r   r      s>    








r   c                  C   sD   t  \} }|g d\}}}|jdksJ tj|g d d S )N)r    r"   r    rD   ff)r   )
rx   rr   rr   rw   rr   rr   rw   rr   rr   rw   )r   r   histshaper;   ri   rj   )figre   nbinspatchesr   r   r   	test_hist  s   r  )r   r.   numpyr;   matplotlib.axesr   matplotlib.pyplotpyplotr   matplotlib.categorycategoryr   r   r>   rA   r   re   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r   r   <module>   s(    .?

A