
    g/                        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      Z G d d      Z G d	 d
      Zej(                  ej*                  ej,                  gZg dZ G d d      Z G d d      Zd Z G d d      Z G d d      Z G d d      Zej>                  jA                  d       edg      d               Z!d Z"d Z#d Z$y)z#Catch all for categorical functions    N)Axes)check_figures_equalc                   p   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        Z
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        Zej                  j                  dee
      d        Zy)TestUnitDatasinglehello worldr   unicode   Здравствуйте мирmixed)Aznp.nanBz3.14   мир)r               z
data, locsidsc                     t        j                  |      }t        |j                  j	                               |k(  sJ t        |j                  j                               |k(  sJ y N)catUnitDatalist_mappingkeysvalues)selfdatalocsunits       [/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/matplotlib/tests/test_category.py	test_unitzTestUnitData.test_unit   sP    ||D!DMM&&()T111DMM((*+t333    c                    ddg}ddg}g d}g d}g d}t        j                  |      }t        |j                  j	                               |k(  sJ t        |j                  j                               |k(  sJ |j                  |       t        |j                  j	                               |k(  sJ t        |j                  j                               |k(  sJ y )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    s          r!   test_updatezTestUnitData.test_update   s    Sz1v%*#||D!DMM&&()T111DMM((*+t333K DMM&&()[888DMM((*+|;;;r#   )numberQ	@nanr   r/      z
mixed typer   r   fdatac                     t        j                  t              5  t        j                  |       d d d        y # 1 sw Y   y xY wr   )pytestraises	TypeErrorr   r   )r   r2   s     r!   test_non_string_failsz"TestUnitData.test_non_string_fails0   s/    ]]9% 	 LL	  	  	 s	   9Ac                     t        j                         }t        j                  t              5  |j                  |       d d d        y # 1 sw Y   y xY wr   )r   r   r4   r5   r6   r)   )r   r2   unitdatas      r!   test_non_string_update_failsz)TestUnitData.test_non_string_update_fails5   s:    <<>]]9% 	#OOE"	# 	# 	#s   A		AN)__name__
__module____qualname__
test_caseszipr   r   r4   markparametrizer"   r-   npr0   failing_test_casesfidsr2   r7   r:    r#   r!   r   r      s   }os34 ABQCHIC,. /0J Z IC[[\4S94 :4
<  +UBFFO!D":.Qx0HJ z"KD%[[We6  7  [[We6# 7#r#   r   c                       e Zd Zd Zy)FakeAxisc                     || _         y r   )units)r   rI   s     r!   __init__zFakeAxis.__init__=   s	    
r#   N)r;   r<   r=   rJ   rE   r#   r!   rG   rG   <   s    r#   rG   c                      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        Zej                   j#                  dee      d        Zej                   j#                  dddgddg      d        Zej                   j#                  dee      d        Zd Zd  Zy!)"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                     t        j                         | _        t        j                         | _        t        | j                        | _        y r   )r   StrCategoryConverterccr   r    rG   ax)r   requests     r!   	mock_axisz"TestStrCategoryConverter.mock_axisX   s/    **,LLN	499%r#   valsr   c                     t         j                  j                  | j                  j	                  || j
                  j                  | j
                        t        t        |                   y r   )	rB   testingassert_allcloserp   convertrq   rI   rangelen)r   rt   s     r!   test_convertz%TestStrCategoryConverter.test_convert_   sB    


""477??43777$<#(T#3	5r#   valuehir   c                 p    | j                   j                  || j                  | j                        dk(  sJ y )Nr   )rp   rx   r    rq   )r   r|   s     r!   test_convert_one_stringz0TestStrCategoryConverter.test_convert_one_stringe   s)    wwudii9Q>>>r#   fvalsc                     t        j                  t              5  | j                  j	                  || j
                  | j                         d d d        y # 1 sw Y   y xY wr   )r4   r5   r6   rp   rx   r    rq   )r   r   s     r!   test_convert_failz*TestStrCategoryConverter.test_convert_faili   s?    ]]9% 	7GGOOE499dgg6	7 	7 	7s   2AAc                     | j                   j                  | j                  | j                        }t	        |j
                  t        j                        sJ t	        |j                  t        j                        sJ y r   )
rp   axisinfor    rq   
isinstancemajlocr   StrCategoryLocatormajfmtStrCategoryFormatter)r   axiss     r!   test_axisinfoz&TestStrCategoryConverter.test_axisinfon   sT    ww		4773$++s'='=>>>$++s'?'?@@@r#   c                     t        | j                  j                  dg| j                        t        j
                        sJ y )Nr%   )r   rp   default_unitsrq   r   r   r   s    r!   test_default_unitsz+TestStrCategoryConverter.test_default_unitss   s-    $''//tww?NNNr#   N)r;   r<   r=   __doc__r>   r?   r   r   rB   infrC   rD   fvaluesr4   fixturers   r@   rA   r{   r   r   r   r   rE   r#   r!   rL   rL   A   sD    @AB]O,_-#c3Z0' *C D	EJ z"KC"T3$78+dBZ8: +,MD'V^^D!& "& [[VV55 65
 [[WtX&6Wi<PQ? R? [[Wg487 97A
Or#   rL   )scatterplotbarc                   Z    e Zd Zd Zej
                  j                  dee      d        Z	y)TestStrCategoryLocatorc                    g d}t        j                  |D cg c]  }t        |       c}      }t        j                  |j                        }t
        j                  j                  |j                  d d       |       y c c}w )N)r   r   r   r   r               	   
   )	r   r   strr   r   rB   rv   assert_array_equaltick_values)r   r   jr    tickss        r!   test_StrCategoryLocatorz.TestStrCategoryLocator.test_StrCategoryLocator|   s^    1||T2SV23&&t}}5


%%e&7&7d&CTJ 3s   Bplotterr   c                     t        j                         j                         } ||g dg d       t        j                  j                  |j                  j                  j                         t        d             y )N)r   r   r   rN   r   )
pltfiguresubplotsrB   rv   r   yaxismajorlocatorry   r   r   rq   s      r!   test_StrCategoryLocatorPlotz2TestStrCategoryLocator.test_StrCategoryLocatorPlot   sK    ZZ\""$I/


%%bhhnn&<&<&>aIr#   N)
r;   r<   r=   r   r4   r@   rA   	PLOT_LISTPLOT_IDSr   rE   r#   r!   r   r   {   s5    K [[Y	x@J AJr#   r   c                      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        Z
ej                  j                  dee      ej                  j                  d	ee      d
               Zy)TestStrCategoryFormatterrM   )helloworldr}   r	      Здравствуйте   приветydatar   c                     t        j                  |      }t        j                  |j                        }t	        |      D ]!  \  }} |||      |k(  sJ  ||d       |k(  r!J  y r   )r   r   r   r   	enumerate)r   r   r    labelsir&   s         r!   test_StrCategoryFormatterz2TestStrCategoryFormatter.test_StrCategoryFormatter   sd    ||E"))$--8e$ 	(DAq!Q<1$$$!T?a'''	(r#   r   c                 T   t        j                         j                         } ||t        t	        |            |       t        |      D ]/  \  }}|j                  j                  j                  |      |k(  r/J  |j                  j                  j                  dz         dk(  sJ y )Nr    )	r   r   r   ry   rz   r   r   r   	formatter)r   r   r   rq   r   r&   s         r!   test_StrCategoryFormatterPlotz6TestStrCategoryFormatter.test_StrCategoryFormatterPlot   s     ZZ\""$E#e*%u-e$ 	4DAq88>>++A.!333	4xx~~''!,222r#   N)r;   r<   r=   r>   r?   r   casesr4   r@   rA   r   r   r   r   rE   r#   r!   r   r      s    459>JKMJ j!JC[[We5( 6( [[We5[[Y	x@3 A 63r#   r   c                 R   t        t        t        |                  }t        j                  j                  | j                         |       |D cg c]  }| j                  j                  ||        }}||D cg c]!  }t        j                  j                  |      # c}k(  sJ t        | j                  j                  j                               |D cg c]  }| c}k(  sJ t        | j                  j                  j                               |k(  sJ y c c}w c c}w c c}w r   )r   ry   rz   rB   rv   r   get_majorticklocsr   r   r   r   _textrI   r   r   r   )r   r   r   r   graph_labelsls         r!   	axis_testr      s    s6{#$EJJ!!$"8"8":EB8=>1DJJ((A.>L>vN!C44::1=NNNN

##((*+6/Ba/BBBB

##**,-666	 ?N/Bs   #D:&D	D$c                       e Zd Zdg dfdg dfd ej                  g d      fgZ ee \  ZZe	j                  j                  dee      e	j                  j                  dee      d	               Zy
)TestPlotBytesstring listrN   
bytes list)   a   b   cbytes ndarrayr   r   bdatac                     t        j                         j                         }t        j                  g d      } ||||       t        |j                  |       y N)r   r   r   r   r   r   rB   arrayr   xaxis)r   r   r   rq   countss        r!   test_plot_byteszTestPlotBytes.test_plot_bytes   @     ZZ\""$)$E6""((E"r#   N)r;   r<   r=   rB   r   bytes_casesr?   	bytes_ids
bytes_datar4   r@   rA   r   r   r   rE   r#   r!   r   r      s    !?3 "45#XRXX.@%ABDK  -Iz[[Y	x@[[Wji@# A A#r#   r   c                      e Zd Zdg dfd ej                  g d      fdg dfd ej                  g d      fgZ ee \  ZZe	j                  j                  dee      e	j                  j                  d	ee      d
               Zy)TestPlotNumliker   )rP   113zstring ndarrayr   )   1s   11   3r   r   r   ndatac                     t        j                         j                         }t        j                  g d      } ||||       t        |j                  |       y r   r   )r   r   r   rq   r   s        r!   test_plot_numlikez!TestPlotNumlike.test_plot_numlike   r   r#   N)r;   r<   r=   rB   r   numlike_casesr?   numlike_idsnumlike_datar4   r@   rA   r   r   r   rE   r#   r!   r   r      s    #%56&1A(BC"$78%xrxx0C'DEGM !$] 3K[[Y	x@[[WlD# E A#r#   r   c                   @   e Zd Zej                  j                  dee      d        Zej                  d        Z
ej                  j                  d      ej                  j                  dee      d               Zej                  j                  d      ej                  j                  dee      d               Zej                  j                  d      ej                  j                  dee      d               Zej                  j                  dee      d	        Z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j0                  ej2                   ej4                  ej6                  ej                  j8                        gZej                  j                  de      ej                  j                  dee      d               Zej                  j                  de      ej                  j                  dee      d               Zy)TestPlotTypesr   r   c                     t        j                         j                         }ddg} |||ddg       t        |j                  |       y )Nr   r   r   r   )r   r   r   r   r   )r   r   rq   wordss       r!   test_plot_unicodezTestPlotTypes.test_plot_unicode   s>    ZZ\""$+^<EAq6""((E"r#   c                 L    g d| _         g d| _        g d| _        g d| _        y )N)r   happyr   )r   r   r   )Pythonisfun)r   r   r   )xxyyyxr   s    r!   	test_datazTestPlotTypes.test_data   s    ,(r#   r   c                     t        j                         j                         } ||| j                  | j                         t        |j                  | j                         y r   )r   r   r   r   r   r   r   r   r   r   rq   s       r!   test_plot_xaxiszTestPlotTypes.test_plot_xaxis   s>     ZZ\""$DFFDGG$"((DFF#r#   c                     t        j                         j                         } ||| j                  | j                         t        |j                  | j                         y r   )r   r   r   r   r   r   r   r   s       r!   test_plot_yaxiszTestPlotTypes.test_plot_yaxis   s>     ZZ\""$DGGTVV$"((DFF#r#   c                    t        j                         j                         } ||| j                  | j                         t        |j                  | j                         t        |j                  | j                         y r   )r   r   r   r   r   r   r   r   r   s       r!   test_plot_xyaxiszTestPlotTypes.test_plot_xyaxis   sP     ZZ\""$DFFDFF#"((DFF#"((DFF#r#   c                     t        j                         j                         } ||ddgddg        ||g dg d        ||g dg d       t        |j                  g d	       t        |j
                  g d
       y Nr%   r'   r(   g)r%   r'   r&   )fr%   r'   )r'   rO   r&   )r  r(   r&   )r%   r'   r&   rO   )r(   r  r  r%   r'   r&   )r   r   r   r   r   r   r   s      r!   test_update_plotzTestPlotTypes.test_update_plot   s`    ZZ\""$S#Jc
+O_5O_5"((01"((:;r#   c                 ,   t        j                         j                         }|j                  ddgddg       |j	                  g dg d       |j                  g dg d       t        |j                  g d	       t        |j                  g d
       y r   )	r   r   r   r   r   r   r   r   r   )r   rq   s     r!   %test_update_plot_heterogenous_plotterz3TestPlotTypes.test_update_plot_heterogenous_plotter   sf    ZZ\""$


C:Sz*
1
0"((01"((:;r#   r   r   r/   znumber integerrP   r   rj   rk   rl   missing12)marksxdatac                     t        j                         j                         }t        j                  t
              5   |||ddg       d d d        y # 1 sw Y   y xY w)Nr   r   r   r   r   r4   r5   r6   r   r   r	  rq   s       r!   test_mixed_type_exceptionz'TestPlotTypes.test_mixed_type_exception  sI     ZZ\""$]]9% 	'B1v&	' 	' 	's   AAc                     t        j                         j                         }t        j                  t
              5   ||ddgddg        |||ddg       d d d        y # 1 sw Y   y xY w)Nr   r   r   r   r  r  s       r!    test_mixed_type_update_exceptionz.TestPlotTypes.test_mixed_type_update_exception  s]     ZZ\""$]]9% 	'BAA'B1v&	' 	' 	's   A  A)N) r;   r<   r=   r4   r@   rA   r   r   r   r   r   usefixturesr   r   r   r  r  rB   r0   rC   r?   rD   r   r   r   r   paramr   xfailplottersr  r  rE   r#   r!   r   r      sA   [[Y	x@# A# ^^  [[[)[[Y	x@$ A *$
 [[[)[[Y	x@$ A *$
 [[[)[[Y	x@$ A *$ [[Y	x@< A<< #S$K0+c1X6+dBZ8$tRVVn57
 +,MD'dhhTYYfkk.?.?@BH [[Y1[[Wg48' 9 2'
 [[Y1[[Wg48' 9 2'r#   r   defaultpng)
extensionsc                    ddl m }  |ddd      } |ddd      } |ddd      } |ddd      }| j                         }|j                         }t        ||gi t        d d       f      D ]  \  }	}
 |	j                  ||gd	d
gfi |
 |	j
                  j                  }|	j                  j                  } |	j                  ||gd	d
gfi |
 ||	j
                  j                  u sJ ||	j                  j                  u rJ  y )Nr   )datetimei  r   r   r   r   )xunitsyunitsV1V2)r  r   r?   dictr   r   rI   r   )fig_testfig_refr  t0t1t2t3ax_testax_refrq   kwargsx_unitsy_unitss                r!   test_overriding_units_in_plotr)    s    "	$1	B	$1	B	$1	B	$1	B!GF7F+t4=>@ 
)
F 	R4,1&1((..((..R4,1&1"((..((("((..(((
)r#   c                      t        j                         \  } }|j                  j                  ddg       |j	                  g g        y)zQ
    Smoke test to check that no deprecation warning is emitted. See #22640.
    r%   r'   N)r   r   r   update_unitsr   r  rq   s     r!   !test_no_deprecation_on_empty_datar-  4  s6     LLNEArHH3*%GGBOr#   c                      t        j                         \  } }|j                  g d      \  }}}|j                  dk(  sJ t        j
                  j                  |g d       y )N)r%   r'   r%   rO   ff)r   )
g       @        r0        ?r0  r0  r1  r0  r0  r1  )r   r   histshaperB   rv   rw   )figrq   nbinspatchess        r!   	test_histr8  =  sN    llnGCww9:AtW77eJJq"JKr#   c                      t        j                         \  } }|j                  g dg d       t        j                         5  |j                  dd       d d d        y # 1 sw Y   y xY w)N)r%   r'   rO   r&   )r   r   r   r   r'   rO   )r   r   r   warningscatch_warningsset_xlimr,  s     r!   test_set_limr=  D  sQ     LLNEArGG ,/		 	 	" 
C  s   AA')%r   r:  r4   numpyrB   
matplotlibmplmatplotlib.axesr   matplotlib.pyplotpyplotr   matplotlib.categorycategoryr   matplotlib.testing.decoratorsr   r   rG   rL   r   r   r   r   r   r   r   r   r   r   r   stylecontextr)  r-  r8  r=  rE   r#   r!   <module>rI     s    )        ! =+# +#\ 
3O 3Ol \\499dhh/	%J J3 307# # # # M' M'` 9() ) ).Lr#   