
    G8cN.                        d 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 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@                  jC                  d       edg      d               Z"d Z#d Z$y)z#Catch all for categorical functions    N)MatplotlibDeprecationWarning)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       @/usr/lib/python3/dist-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   r0      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   r3   s     r"   test_non_string_failsz"TestUnitData.test_non_string_fails/   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   r5   r6   r7   r*   )r   r3   unitdatas      r"   test_non_string_update_failsz)TestUnitData.test_non_string_update_fails4   s:    <<>]]9% 	#OOE"	# 	# 	#s   A		AN)__name__
__module____qualname__
test_caseszipr   r   r5   markparametrizer#   r.   npr1   failing_test_casesfidsr3   r8   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   rJ   s     r"   __init__zFakeAxis.__init__<   s	    
r$   N)r<   r=   r>   rK   rF   r$   r"   rH   rH   ;   s    r$   rH   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d Z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   r0   r   string integer42*   T)autousec                     t        j                         | _        t        j                         | _        t        | j                        | _        y r   )r   StrCategoryConverterccr   r!   rH   ax)r   requests     r"   	mock_axisz"TestStrCategoryConverter.mock_axisW   s/    **,LLN	499%r$   valsr   c                     t         j                  j                  | j                  j	                  || j
                  j                  | j
                        t        t        |                   y r   )	rC   testingassert_allcloserq   convertrr   rJ   rangelen)r   ru   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   )rq   ry   r!   rr   )r   r}   s     r"   test_convert_one_stringz0TestStrCategoryConverter.test_convert_one_stringd   s)    wwudii9Q>>>r$   c                 *   t        j                  t              5  | j                  j	                  d| j
                  | j                        }d d d        t        j                  j                  t        j                  dg             y # 1 sw Y   >xY w)N        )r5   warnsr   rq   ry   r!   rr   rC   rw   rx   array)r   actuals     r"   test_convert_one_numberz0TestStrCategoryConverter.test_convert_one_numberh   s`    \\67 	>WW__S$))TWW=F	>


""6288RD>:	> 	>s   2B		Bc                 f   t        j                  g dt              }t        j                  t
              5  | j                  j                  || j                  | j                        }d d d        t         j                  j                  t        j                  g d             y # 1 sw Y   ?xY w)Nr   r   r   )dtype)      ?       @g      @)rC   r   floatr5   r   r   rq   ry   r!   rr   rw   rx   )r   r   r   s      r"   test_convert_float_arrayz1TestStrCategoryConverter.test_convert_float_arraym   so    xx	/\\67 	?WW__T499dgg>F	?


""6288L+AB	? 	?s   2B''B0fvalsc                     t        j                  t              5  | j                  j	                  || j
                  | j                         d d d        y # 1 sw Y   y xY wr   )r5   r6   r7   rq   ry   r!   rr   )r   r   s     r"   test_convert_failz*TestStrCategoryConverter.test_convert_fails   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   )
rq   axisinfor!   rr   
isinstancemajlocr   StrCategoryLocatormajfmtStrCategoryFormatter)r   axiss     r"   test_axisinfoz&TestStrCategoryConverter.test_axisinfox   sT    ww		4773$++s'='=>>>$++s'?'?@@@r$   c                     t        | j                  j                  dg| j                        t        j
                        sJ y )Nr&   )r   rq   default_unitsrr   r   r   r   s    r"   test_default_unitsz+TestStrCategoryConverter.test_default_units}   s-    $''//tww?NNNr$   N)r<   r=   r>   __doc__r?   r@   r   r   rC   infrD   rE   fvaluesr5   fixturert   rA   rB   r|   r   r   r   r   r   r   rF   r$   r"   rM   rM   @   sO    @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?;
C [[Wg487 97A
Or$   rM   )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   rC   rw   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 )Nr   rO   r   )
pltfiguresubplotsrC   rw   r   yaxismajorlocatorrz   r   r   rr   s      r"   test_StrCategoryLocatorPlotz2TestStrCategoryLocator.test_StrCategoryLocatorPlot   sK    ZZ\""$I/


%%bhhnn&<&<&>aIr$   N)
r<   r=   r>   r   r5   rA   rB   	PLOT_LISTPLOT_IDSr   rF   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)TestStrCategoryFormatterrN   )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   rz   r{   r   r   r   	formatter)r   r   r   rr   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   casesr5   rA   rB   r   r   r   r   rF   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   rz   r{   rC   rw   r   get_majorticklocsr   r   r   r   _textrJ   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 listrO   
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   rC   r   r   xaxis)r   r   r   rr   countss        r"   test_plot_byteszTestPlotBytes.test_plot_bytes   @     ZZ\""$)$E6""((E"r$   N)r<   r=   r>   rC   r   bytes_casesr@   	bytes_ids
bytes_datar5   rA   rB   r   r   r   rF   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   )rQ   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   rr   r   s        r"   test_plot_numlikez!TestPlotNumlike.test_plot_numlike   r   r$   N)r<   r=   r>   rC   r   numlike_casesr@   numlike_idsnumlike_datar5   rA   rB   r   r   r   rF   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
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j0                   ej2                  ej4                  ej                  j6                        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   rr   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   rr   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(   rP   r'   )r  r)   r'   )r&   r(   r'   rP   )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$   r   r   r0   znumber integerrQ   r   rk   rl   rm   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   r5   r6   r7   r   r   r  rr   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>   r5   rA   rB   r   r   r   r   r  usefixturesr  r	  r  r  rC   r1   rD   r@   rE   r   r   r   r   paramr   xfailplottersr  r  rF   r$   r"   r   r      s<   [[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   rJ   r   )fig_testfig_refr"  t0t1t2t3ax_testax_refrr   kwargsx_unitsy_unitss                r"   test_overriding_units_in_plotr3    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  rr   s     r"   !test_no_deprecation_on_empty_datar6  6  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&   rP   ff)r   )
r   r   r   r   r   r   r   r   r   r   )r   r   histshaperC   rw   rx   )figrr   nbinspatchess        r"   	test_histr?  ?  sN    llnGCww9:AtW77eJJq"JKr$   )%r   r5   numpyrC   
matplotlibmplmatplotlib._apir   matplotlib.axesr   matplotlib.pyplotpyplotr   matplotlib.categorycategoryr   matplotlib.testing.decoratorsr   r   rH   rM   r   r   r   r   r   r   r   r   r   r   r   stylecontextr3  r6  r?  rF   r$   r"   <module>rL     s    )    8    ! =+# +#\ 
>O >OB \\499dhh/	%J J3 307# # # # E' E'P 9() ) ).Lr$   