o
    tBh                     @   s,  d dl mZ d dlZd dlZd dlZd dlZd dlmZm	Z	 d dl
Z
d dl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G d
d dZG dd dZG dd dZG dd dZG dd dZG dd dZG dd dZG dd dZG dd dZG dd dZG dd dZ G d d! d!Z!G d"d# d#Z"G d$d% d%Z#G d&d' d'Z$G d(d) d)Z%G d*d+ d+Z&G d,d- d-Z'd.d/ Z(G d0d1 d1Z)d2d3 Z*d4d5 Z+d6d7 Z,d8d9 Z-d:d; Z.e
j/0d<d=d>d? Z1e
j/0d@dAdBge2dCgdDdE Z3e
j/0dFg dGej45dHdIdJ Z6dS )K    )nullcontextN)assert_almost_equalassert_array_equalc                
   @   s   e Zd Zddeg dfddeg dfddeg d	fd
dedd fdd
eddd fgZdddeg dfdddeg dfddg deg dfgZej	
dedd Zej	
dedd ZdS ) TestMaxNLocator   d   )      4@g      D@g      N@g      T@      Y@MbP?-C6?)        g-C6*?g-C6:?ga2U0*C?g-C6J?r
     4&k  4&kC)r   g  4&kr   g  4&kBr   r   g&q5   gLog5g&q   皙皙?N)r   r      ffffff?)g      пr         ?      ?      ?      ?7   )r         ?   r   
   )r         -   <   zvmin, vmax, expectedc                 C   s"   t jdd}t|||| d S )Nr   nbinsmtickerMaxNLocatorr   tick_values)selfvminvmaxexpectedloc r.   s/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/matplotlib/tests/test_ticker.py
test_basic   s   zTestMaxNLocator.test_basiczvmin, vmax, steps, expectedc                 C   s&   t jdd|d}t|||| d S )Nr   T)r$   integerstepsr%   )r)   r*   r+   r2   r,   r-   r.   r.   r/   test_integer#   s   zTestMaxNLocator.test_integer)__name__
__module____qualname__nparrayarange
basic_datainteger_datapytestmarkparametrizer0   r3   r.   r.   r.   r/   r      s    	
r   c                   @   s   e Zd Zdd Zdd ZdS )TestLinearLocatorc                 C   0   t jdd}tg d}t|dd| d S )N   numticks)皙g333333ӿ皙?rD   rE   )r&   LinearLocatorr7   r8   r   r(   r)   r-   
test_valuer.   r.   r/   r0   *   s   zTestLinearLocator.test_basicc                 C   sB   t jdd}|jddg id |jdksJ |jdg iksJ dS )z
        Create linear locator with presets={}, numticks=2 and change it to
        something else. See if change was successful. Should not exception.
        r   rB      )r   r   )rC   presetsN)r&   rF   
set_paramsrC   rJ   r)   r-   r.   r.   r/   test_set_params/   s   z!TestLinearLocator.test_set_paramsN)r4   r5   r6   r0   rM   r.   r.   r.   r/   r?   )   s    r?   c                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
TestMultipleLocatorc                 C   r@   )NV-	@base)go"V-gV-	r   rO   V-@go"@gV-)@r   )r&   MultipleLocatorr7   r8   r   r(   rG   r.   r.   r/   r0   ;   s   zTestMultipleLocator.test_basicc                 C   R   t ddi tjdd}t|ddd W d   dS 1 s"w   Y  dS )	z5
        Test basic behavior of view limits.
        axes.autolimit_modedatarO   rP   r   r   )r   r   Nmpl
rc_contextr&   rU   r   view_limitsrL   r.   r.   r/   test_view_limitsA   s   "z$TestMultipleLocator.test_view_limitsc                 C   rV   )	zb
        Test that everything works properly with 'round_numbers' for auto
        limit.
        rW   round_numbersrO   rP      )rR   rS   NrY   rL   r.   r.   r/   test_view_limits_round_numbersI   s   "z2TestMultipleLocator.test_view_limits_round_numbersc                 C   s,   t jdd}|jdd |jjdksJ dS )z
        Create multiple locator with 0.7 base, and change it to something else.
        See if change was successful.
        ffffff?rP   g333333?N)r&   rU   rK   _edgestep)r)   multr.   r.   r/   rM   R   s   z#TestMultipleLocator.test_set_paramsN)r4   r5   r6   r0   r]   ra   rM   r.   r.   r.   r/   rN   :   s
    	rN   c                	   @   s   e Zd Zdd ZddgZejdedd Zg dZ	d	d
 Z
ejde	dd Zg dZg dg dg dg dg dg dg dg dgZeeeeZejdedd ZdS )TestAutoMinorLocatorc                 C   sF   t  \}}|dd |  tg d}t|jjdd| d S )Nr   =
ףp=?皙?皙?g333333?r   g333333?gffffff??r   皙?g?rb   r   g333333??r   g?r   gffffff?g      ?g?g?Tminor)	pltsubplotsset_xlimminorticks_onr7   r8   r   xaxisget_ticklocs)r)   figaxrH   r.   r.   r/   r0   ]   s
   zTestAutoMinorLocator.test_basicr   r   )r   r   z%nb_majorticks, expected_nb_minorticksc                 C   sh   t  \}}d}|j|  |t|d |d | |  |jt	
  t|j |ks2J d S )N)r   r   r   r   )rp   rq   rr   
set_xticksr7   linspacers   rt   set_minor_locatorr&   AutoMinorLocatorlenget_minorticklocs)r)   nb_majorticksexpected_nb_minorticksrv   rw   xlimsr.   r.   r/   test_low_number_of_majorticksl   s   
z2TestAutoMinorLocator.test_low_number_of_majorticks))r   r   )r   r`   )      @r   )r   r   )r   r   c                 C   sX   t ddi dd | jD }tj|t j W d    d S 1 s%w   Y  d S )Nz_internal.classic_modeFc                 S   s   g | ]}|d  qS r   r.   .0xr.   r.   r/   
<listcomp>       zKTestAutoMinorLocator.test_using_all_default_major_steps.<locals>.<listcomp>)	rZ   r[   majorstep_minordivisionsr7   testingassert_allcloser&   AutoLocator_steps)r)   
majorstepsr.   r.   r/   "test_using_all_default_major_steps   s   "z7TestAutoMinorLocator.test_using_all_default_major_stepsz&major_step, expected_nb_minordivisionsc                 C   sb   t  \}}d|f}|j|  || |  |jt  t	|j
 d }||ks/J d S Nr   r   )rp   rq   rr   ry   rs   rt   r{   r&   r|   r}   r~   )r)   
major_stepexpected_nb_minordivisionsrv   rw   r   nb_minor_divisionsr.   r.   r/   test_number_of_minor_ticks   s   

z/TestAutoMinorLocator.test_number_of_minor_ticks))r   rg   )r   gn?)r   ԍ;)r   gVs?=)gH׊gIhG|a)gv!>ҷ>)ʔA{v()g"s2_dglEՎfUrh   ){Gzt?{Gz?Q?g?gQ?gQ?g
ףp=
?ri   g)\(?gp=
ף?gQ?g333333?g(\µ?g
ףp=
?gRQ?gzG?)\(?gq=
ףp?g      ?gp=
ף?gHzG?)gO
;gO
;gU;g#B;gU;g̈=;gnP*@;g#B;gԍ;gaW;g̈=;gmx;gJ;gnP*@;gnXen;g+3M;r   )g+<g+=gt=gvIh%=gt =g(#=gQu.U)=gvIh%,=gU.=gnb]K2=g(3=g7Q5=gU>?7=gQu.U9=gc߯x:=g; ==gU>=)g*#&,gYg#"5Ԉg_eG|gS'цgBY[%gk̈́gv!g|)vgQ؎gqrgƀg%e~gw$}g߈/|gYygv(xgS'vgv!tgz]rgqrqgw$mgHjgv(hgz]b)gL>gE/w>gZMϢ>gkʹ>g	ʧ#>g!+lěN>g:0y>gR>g};h>gBY[%>gqwNP>gʔA{>gS'Ѷ>g>g.W'>gG)R>gxz)e秷>r   )g5m/Gg<gT跾g`gxz)e秷gIGmg肸zggG)Rg<g&|gg5_涾gqdqAg34gY#)g#"5Ըg_~r   gҷg.W'gS'Ѷr   gBY[%g:0yg	ʧ#gkʹgE/wgE̳g|)vg<sAC gz]ʲgQ؎g 4PSȱgqrg>g\+-eqg+i)+gM7܉g%eޮgw$zlim, refc                 C   sZ   t  \}}|  |jddddd |jddddd || t|jjdd	| d S )
NTro   yr   )	linewidthmajork)colorr   rn   )rp   rq   rs   gridset_ylimr   yaxisru   )r)   limrefrv   rw   r.   r.   r/   test_additional   s   
z$TestAutoMinorLocator.test_additionalN)r4   r5   r6   r0   paramsr<   r=   r>   r   r   r   r   limits	referencelistzipadditional_datar   r.   r.   r.   r/   rf   \   s4    

rf   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestLogLocatorc                 C   s   t jdd}tt |dd W d    n1 sw   Y  tg d}t|dd| t jdd	}tg d
}t|dd| d S )Nr   rB   r     )h㈵>r
   rj         $@     @@     j@g    cA    eAr
   g     @r   rP   )
r   r          @      @g       @g      0@g      @@g      P@g      `@g      p@r   r   )	r&   
LogLocatorr<   raises
ValueErrorr(   r7   r8   r   rG   r.   r.   r/   r0      s   zTestLogLocator.test_basicc                 C   sb   t jdd}t|ddg d t jtddd}d|d	d
vs%J d|d	d
vs/J d S )Nallsubsrk   rl   )g)\(?gq=
ףp?gQ?r   gp=
ף?gHzG?gQ?r   r   r   rm   r   r   )r&   r   r   r(   r7   r9   rL   r.   r.   r/   test_switch_to_autolocator   s   z)TestLogLocator.test_switch_to_autolocatorc                 C   s^   t  }|jdddgdd |jdksJ |jdksJ |jdks#J t|jdgks-J dS )z
        Create log locator with default value, base=10.0, subs=[1.0],
        numdecs=4, numticks=15 and change it to something else.
        See if change was successful. Should not raise exception.
           rI   r   r`   )rC   numdecsr   rQ   N)r&   r   rK   rC   r   _baser   _subsrL   r.   r.   r/   rM      s   zTestLogLocator.test_set_paramsN)r4   r5   r6   r0   r   rM   r.   r.   r.   r/   r      s    	r   c                   @      e Zd Zdd ZdS )TestNullLocatorc                 C   s@   t  }tt |  W d   dS 1 sw   Y  dS )z
        Create null locator, and attempt to call set_params() on it.
        Should not exception, and should raise a warning.
        N)r&   NullLocatorr<   warnsUserWarningrK   rL   r.   r.   r/   rM      s   
"zTestNullLocator.test_set_paramsNr4   r5   r6   rM   r.   r.   r.   r/   r          r   c                   @   s$   e Zd Zedd Zedd ZdS )_LogitHelperc                 C   s`   d|   k r
dk r.n n"d|  k rdk r.n nt t d|  d  t d| d  S dS )Nr   r   F)r7   iscloselog)r   r   r.   r.   r/   r      s   0,z_LogitHelper.isclosec                 C   s   t | }t |}t |dkrt |dk sJ t |dkr(t |dk s*J t d| d  }t d| d  }t|| d S r   )r7   r8   r   r   r   )r   r   rw   aylxlyr.   r.   r/   r      s   

  z _LogitHelper.assert_almost_equalN)r4   r5   r6   staticmethodr   r   r.   r.   r.   r/   r      s
    
r   c                   @   s  e Zd Zg dZddedd  ddedd  ddedd  ddedd  ddedd  ddedd	  ddedd
  ddedd  gZg dZej	
deeedd Zej	
dedd Zej	
dee dd Zej	
deeedd Zdd Zg dedd ddedd  Zej	
ddd ejeddD dd  Zej	
d!ed"d# Zd$S )%TestLogitLocator)ri   r   )r   gףp=
?)gMb@?gCl?-C6
?gSt$?)gh㈵>g;?)gƠ>g?gHj>ge(?)g:0y5>g$P?r   r   rA   r`   r   r   r   rI   	   ))g?g333333?)ri   rE   )g?r   zlims, expected_low_ticksc                 C   s:   t g |dd| }tjdd}t|j| | dS )zR
        Create logit locator with huge number of major, and tests ticks.
        r   r   r   r#   N)sortedr&   LogitLocatorr   r   r(   )r)   limsexpected_low_ticksexpected_ticksr-   r.   r.   r/   test_basic_major  s   z!TestLogitLocator.test_basic_majorr   c                 C   sx   t jdd}t jdg dd}dD ](}|j|d |j|d |j| }|j| }|j|jks1J ||k s9J qdS )zj
        When the axis is zoomed, the locator must have the same behavior as
        MaxNLocator.
        r   r#   )r   r   r   r   )r$   r2   )r`   rI      N)r&   r   r'   rK   r(   shaper   )r)   r   r-   maxn_locr$   ticks
maxn_ticksr.   r.   r/   test_maxn_major/  s   

z TestLogitLocator.test_maxn_majorc                 C   sj   t tt|d  d d }tjdd}t|ddD ]}|j|d t|j	| |d ks2J qdS )zB
        Assert logit locator for respecting nbins param.
        r   r   r   r   r#   r   N)
intr7   floorlog10r&   r   rangerK   r}   r(   )r)   r   basic_neededr-   r$   r.   r.   r/   test_nbins_major?  s   "z!TestLogitLocator.test_nbins_majorc           
      C   s   t g |dd| }t|}tjdd}tjddd}t|ddD ];}|j|d |j|d |j| }|j| }	t|t|krRt|d d	 t|	k sQJ q#tt g ||	| q#d
S )zt
        In large scale, test the presence of minor,
        and assert no minor when major are subsampled.
        r   r   r   r#   T)r$   ro   r   r   r   N)	r   r}   r&   r   r   rK   r(   r   r   )
r)   r   r   r   r   r-   	minor_locr$   major_ticksminor_ticksr.   r.   r/   
test_minorK  s"   


zTestLogitLocator.test_minorc                 C   s@   t jdd}|jrJ d|_|jsJ |jdd |jrJ d S )Nr   r#   TFrn   )r&   r   ro   rK   rL   r.   r.   r/   test_minor_attrh  s   

z TestLogitLocator.test_minor_attrr   r   c                 C   s    g | ]\}}||kr||fqS r.   r.   )r   abr.   r.   r/   r   w  s
    zTestLogitLocator.<listcomp>r   )repeatc                 C   s*   t  }|j| }t|t|ksJ dS )zd
        Create logit locator, and test the nonsingular method for acceptable
        value
        N)r&   r   nonsingularr   )r)   r   r-   lims2r.   r.   r/   test_nonsingular_oku  s   
z$TestLogitLocator.test_nonsingular_okokvalc                 C   s   t  }d|}}|||\}}||ksJ d|  k r"|k s%J  J |d}}|||\}}||ks8J ||  k rCdk sFJ  J dS )zh
        Create logit locator, and test the nonsingular method for non
        acceptable value
        r   r   r   r   N)r&   r   r   )r)   r   r-   r*   r+   vmin2vmax2r.   r.   r/   test_nonsingular_nok  s   

 z%TestLogitLocator.test_nonsingular_nokN)r4   r5   r6   ref_basic_limitsr7   r9   ref_basic_major_ticksref_maxn_limitsr<   r=   r>   r   r   r   r   r   r   acceptable_vmin_vmax	itertoolsproductr   r   r.   r.   r.   r/   r     sR    




	r   c                   @   r   )TestFixedLocatorc                 C   s2   t jtdddd}|jdd |jdksJ dS )z
        Create fixed locator with 5 nbins, and change it to something else.
        See if change was successful.
        Should not exception.
        r      r   r#   r   N)r&   FixedLocatorr   rK   r$   )r)   fixedr.   r.   r/   rM     s   z TestFixedLocator.test_set_paramsNr   r.   r.   r.   r/   r     r   r   c                   @   r   )TestIndexLocatorc                 C   s<   t jddd}|jddd |jdksJ |jdksJ dS )z
        Create index locator with 3 base, 4 offset. and change it to something
        else. See if change was successful.
        Should not exception.
        rA   r`   )rQ   offsetr   N)r&   IndexLocatorrK   r   r  )r)   indexr.   r.   r/   rM     s   z TestIndexLocator.test_set_paramsNr   r.   r.   r.   r/   r    r   r  c                   @   r   )TestSymmetricalLogLocatorc                 C   s@   t jddd}|jdgdd |jdgksJ |jdksJ dS )z
        Create symmetrical log locator with default subs =[1.0] numticks = 15,
        and change it to something else.
        See if change was successful.
        Should not exception.
        r   r   )rQ   	linthreshr   rI   )r   rC   N)r&   SymmetricalLogLocatorrK   r   rC   )r)   symr.   r.   r/   rM     s   z)TestSymmetricalLogLocator.test_set_paramsNr   r.   r.   r.   r/   r    r   r  c                   @   s   e Zd Zg dZddgZg dZddgddgd	d
gddgddggZg dZej	
dddgdd Zej	
dedd Zej	
dedd Zdd Zej	
dedd Zej	
d ed!d" Zej	
d#ed$d% Zej	
d#ed&d' Zd(d) Zd*S )+TestScalarFormatter)){      r   )iCir   )i50  i=0  i40  )iii)g    i@g    j@順 )g    jg    i`y)g    hi@g    j@r  )g    jg    hir  )iO iQ iP )i+i+i+)r   r   r   )r  r  r   )g/'?g_L?rk   )g
ףp=@g33333@i  )g@g    `@iȯ  )g1е/G?gg޻G?g9̗G?)g\h@gp=
@i.1  )g      "@g      (@r   )g      @     @r   )g     @r  r   )Gz?g)\(?r   )g{G#@gQ$@r   )g(\X@gq=
ף Y@r   )g(\@g
ףp=
@r   )g{G/@g(\0@r   )g!rhܿrh|?r   )grh|߿r  r   )g3333@g    @@i0  )gffffgffff@r   TF)	)Frx   )r   r   r   F)Tr   )ir   r   F)Tr  )ir   r   F)Tr  )ix   r   F)Tr  )in   r   F)Tr  )gMbPgMb`?r   F)T)rT   r   )g   tAg   0Ar   T)Trx   g     jr   r   F)T)r   r   r  r   Fr   z0.000g(0?z0.012grh|?z0.123gGz?z1.230g(@z12.300))rj   1e-1)r   z1.1e-1)g    חA1e8)g    9Az1.1e8zunicode_minus, result)T   −1)F-1c                 C   s.   |t jd< t j d |ksJ d S )Naxes.unicode_minusr   )rZ   rcParamsrp   gcart   get_major_formatterformat_data_shortstrip)r)   unicode_minusresultr.   r.   r/   test_unicode_minus  s   
z&TestScalarFormatter.test_unicode_minuszleft, right, offsetc                 C   s   t  \}}|j }||krtjtddnt  ||| W d    n1 s*w   Y  |j	  |j
|ks;J ||krFtjtddnt  ||| W d    n1 sZw   Y  |j	  |j
|kskJ d S )NzAttempting to set identicalmatch)rp   rq   rt   r  r<   r   r   r   rr   _update_ticksr  )r)   leftrightr  rv   rw   	formatterr.   r.   r/   test_offset_value  s$   


z%TestScalarFormatter.test_offset_value
use_offsetc                 C   sL   t d|i t }|| ksJ W d    d S 1 sw   Y  d S )Nzaxes.formatter.useoffset)rZ   r[   r&   ScalarFormatterget_useOffset)r)   r,  tmp_formr.   r.   r/   test_use_offset  s   "z#TestScalarFormatter.test_use_offsetc                 C   s   t  }|d }|r|d dd  g t jgfv rtd tddi- t }|	 s/J |
  |jdd |g d	 ||d
v sIJ W d    d S 1 sTw   Y  d S )Nthousands_sepgroupingr   zLocale does not apply groupingzaxes.formatter.use_localeTr   r   )r   r   rA   r   )locale
localeconvCHAR_MAXr<   skiprZ   r[   r&   r-  get_useLocalecreate_dummy_axisaxisset_data_intervalset_locs)r)   convsepr/  r.   r.   r/   test_use_locale  s    
"z#TestScalarFormatter.test_use_localez.sci_type, scilimits, lim, orderOfMag, fewticksc           	      C   sv   t  }|| || t \}}|j| |j|  |r*|j	t 
d ||j  ||jks9J d S )Nr`   )r&   r-  set_scientificset_powerlimitsrp   rq   r   set_major_formatterr   set_major_locatorr'   r;  get_majorticklocsorderOfMagnitude)	r)   sci_type	scilimitsr   
orderOfMagfewticksr/  rv   rw   r.   r.   r/   test_scilimits,  s   


z"TestScalarFormatter.test_scilimitszvalue, expectedc                 C   s(   dt jd< t }|||ksJ d S )NFr  )rZ   r  r&   r-  format_data)r)   valuer,   sfr.   r.   r/   test_format_data;  s   
z$TestScalarFormatter.test_format_datazdata, expectedc                 C   s8   t  \}}|dd |j j}|||ksJ d S )Nr   r   )rp   rq   rr   rt   r  r   )r)   rX   r,   rv   rw   fmtr.   r.   r/   test_cursor_precisionA  s   z)TestScalarFormatter.test_cursor_precisionc                 C   s8   t  }|  |jdd |j}|||ksJ d S )Nr   r   )r&   r-  r8  r9  set_view_intervalr   )r)   rX   r,   rL  rN  r.   r.   r/   test_cursor_dummy_axisH  s
   z*TestScalarFormatter.test_cursor_dummy_axisc                 C   sl   t jdddd tjtdd t \}}|g d |j	
  W d    d S 1 s/w   Y  d S )Nserifcmr10F)zfont.familyz
font.serifzaxes.formatter.use_mathtextzcmr10 font should ideallyr%  )r   r   r   )rZ   r  updater<   r   r   rp   rq   ry   canvasdraw)r)   rv   rw   r.   r.   r/   test_mathtext_ticksQ  s   "z'TestScalarFormatter.test_mathtext_ticksN)r4   r5   r6   offset_datause_offset_datascilimits_datacursor_datarJ  r<   r=   r>   r$  r+  r0  r>  rI  rM  rO  rQ  rW  r.   r.   r.   r/   r    s>    !






r  c                   @   s"   e Zd ZdZd	ddZdd ZdS )
FakeAxiszAAllow Formatter to be called without having a "full" plot set up.r   r   c                 C   s   || _ || _d S Nr*   r+   )r)   r*   r+   r.   r.   r/   __init__`  s   
zFakeAxis.__init__c                 C   s   | j | jfS r]  r^  )r)   r.   r.   r/   get_view_intervald  s   zFakeAxis.get_view_intervalNr   r   )r4   r5   r6   __doc__r_  r`  r.   r.   r.   r/   r\  ^  s    
r\  c                   @   s   e Zd Zddeddeddg dfddedd	ejd
ddgedg dfddejg dededg dfgZ	dddejej
gZejde	ejdedd Zdd ZdS )TestLogFormatterExponentTr`   r   r   )z-3z-2r  0123Fr   rj   r   rE   gɿgh㈵r   )0.1z1e-053.14z0.2z-0.2z-1e-052   )rA   r      *   dtype)rg  51242r   g      @r   z2labelOnlyBase, exponent, locs, positions, expectedrQ   c           	         sN   t j||d td||  _|| } fddt||D }||ks%J d S )NrQ   labelOnlyBaser   c                    s   g | ]	\}} ||qS r.   r.   )r   r   posr*  r.   r/   r         z7TestLogFormatterExponent.test_basic.<locals>.<listcomp>)r&   LogFormatterExponentr\  r9  r   )	r)   rs  rQ   exponentlocs	positionsr,   valslabelsr.   ru  r/   r0   v  s   z#TestLogFormatterExponent.test_basicc                 C   s*   t jddd}t |_|ddksJ d S )Nr   Trr  g&$? )r&   rw  r\  r9  )r)   r*  r.   r.   r/   
test_blank  s   z#TestLogFormatterExponent.test_blankN)r4   r5   r6   r7   r9   r8   pir   float
param_datae	base_datar<   r=   r>   r0   r~  r.   r.   r.   r/   rc  h  s$    	rc  c                   @   s2   e Zd Ze Zg dZej	dedd Z
dS )TestLogFormatterMathtext))r   r   $\mathdefault{10^{0}}$)r   r   z$\mathdefault{10^{-2}}$)r   r	   z$\mathdefault{10^{2}}$)rA   r   z$\mathdefault{1}$)rA   r   z$\mathdefault{0.01}$)rA   r	   z$\mathdefault{100}$)rA   r
   z$\mathdefault{10^{-3}}$)rA   r   z$\mathdefault{10^{3}}$zmin_exponent, value, expectedc                 C   sF   t d|i | ||ksJ W d    d S 1 sw   Y  d S )Nzaxes.formatter.min_exponent)rZ   r[   rN  )r)   min_exponentrK  r,   r.   r.   r/   test_min_exponent  s   "z*TestLogFormatterMathtext.test_min_exponentN)r4   r5   r6   r&   LogFormatterMathtextrN  	test_datar<   r=   r>   r  r.   r.   r.   r/   r    s
    r  c                   @   s6   e Zd Zg dZejdej	dedd Z
dS )TestLogFormatterSciNotation))r   g      ?z$\mathdefault{2^{-5}}$)r   r   z$\mathdefault{2^{0}}$)r       z$\mathdefault{2^{5}}$)r   g333333?z$\mathdefault{1.2\times2^{-5}}$)r   333333?z$\mathdefault{1.2\times2^{0}}$)r   g333333C@z$\mathdefault{1.2\times2^{5}}$)r   r   z$\mathdefault{-10^{0}}$)r   r   z$\mathdefault{10^{-5}}$)r   r   r  )r   r  z$\mathdefault{10^{5}}$)r   gh㈵>z$\mathdefault{2\times10^{-5}}$)r   r   z$\mathdefault{2\times10^{0}}$)r   i@ z$\mathdefault{2\times10^{5}}$)r   r   z$\mathdefault{5\times10^{-5}}$)r   r   z$\mathdefault{5\times10^{0}}$)r   i  z$\mathdefault{5\times10^{5}}$defaultzbase, value, expectedc                 C   sZ   t j|d}h d|_tddi |||ksJ W d    d S 1 s&w   Y  d S )NrP   >   r  r   r   r   text.usetexF)r&   LogFormatterSciNotationsublabelrZ   r[   )r)   rQ   rK  r,   r*  r.   r.   r/   r0     s
   
"z&TestLogFormatterSciNotation.test_basicN)r4   r5   r6   r  rZ   stylecontextr<   r=   r>   r0   r.   r.   r.   r/   r    s
    
r  c                   @   s|   e Zd Zg dZejdedd ZdddZe	j
dd	d
 Zejdg ddd Zejdg ddd ZdS )TestLogFormatter))}9x ?r
   z3.142e-5)Gŷ4?r
   z3.142e-4)ei?r
   z3.142e-3)\, ?r
   z3.142e-2)s7v/?r
   z3.142e-1)PERT!	@r
   3.142)f)zj?@r
   z3.142e1)&FYs@r
   z3.142e2)WXp/@r
   z3.142e3)mnL@r
   z3.142e4),Ar
   z3.142e5)r   r
   1e-5)r   r
   1e-4)r
   r
   1e-3)r   r
   1e-2)rj   r
   r  )r   r
   re  )r   r
   10)r   r
   100)r   r
   1000)'  r
   1e4)r  r
   1e5)r  r   rd  )r  r   rd  )r  r   0.003)r  r   0.031)r  r   0.314)r  r   r  )r  r   31.416)r  r   314.159)r  r   3141.593)r  r   	31415.927)r  r   
314159.265)r   r   rd  )r   r   rd  )r
   r   0.001)r   r   0.01)rj   r   rh  )r   r   re  )r   r   r  )r   r   r  )r   r   r  )r  r   10000)r  r   100000)r  r   rd  )r  r   rd  )r  r   r  )r  r   r  )r  r   r  )r  r   r  )r  r   r  )r  r   r  )r  r   r  )r  r   r  )r  r   r  )r   r   rd  )r   r   rd  )r
   r   r  )r   r   r  )rj   r   rh  )r   r   re  )r   r   r  )r   r   r  )r   r   r  )r  r   r  )r  r   r  )r  r   rd  )r  r   rd  )r  r   rd  )r  r   z0.03)r  r   z0.31)r  r   ri  )r  r   z31.42)r  r   z314.16)r  r   z3141.59)r  r   z31415.93)r  r   z	314159.27)r   r   rd  )r   r   rd  )r
   r   rd  )r   r   r  )rj   r   rh  )r   r   re  )r   r   r  )r   r   r  )r   r   r  )r  r   r  )r  r   r  )r  r   rd  )r  r   rd  )r  r   rd  )r  r   rd  )r  r   z0.3)r  r   3.1)r  r   z31.4)r  r   z314.2)r  r   z3141.6)r  r   z31415.9)r  r   z314159.3)r   r   rd  )r   r   rd  )r
   r   rd  )r   r   rd  )rj   r   rh  )r   r   re  )r   r   r  )r   r   r  )r   r   r  )r  r   r  )r  r   r  )r      .Az3.1e-5)r  r  z3.1e-4)r  r  z3.1e-3)r  r  z3.1e-2)r  r  z3.1e-1)r  r  r  )r  r  z3.1e1)r  r  z3.1e2)r  r  z3.1e3)r  r  z3.1e4)r  r  z3.1e5)r   r  r  )r   r  r  )r
   r  r  )r   r  r  )rj   r  r  )r   r  re  )r   r  r  )r   r  r  )r   r  r  )r  r  r  )r  r  r  zvalue, domain, expectedc                 C   s$   t  }|||}||ksJ d S r]  )r&   LogFormatter_pprint_val)r)   rK  domainr,   rN  labelr.   r.   r/   test_pprintA  s   zTestLogFormatter.test_pprintr.   c                    sf   |   | } | |dtt|  }fdd|D } fdd|D }||ks1J dS )z.Test whether locator marks subs to be labeled.r   c                    s   g | ]}t | v qS r.   )round)r   cr   r.   r/   r   M      z0TestLogFormatter._sub_labels.<locals>.<listcomp>c                       g | ]} |d kqS r}  r.   r   rN  r.   r/   r   N  r  N)get_minor_formatterr~   r;  r7   r   r   )r)   r9  r   minor_tlocscoefslabel_expected
label_testr.   )rN  r   r/   _sub_labelsG  s   
zTestLogFormatter._sub_labelsr  c                    sR  t  \}}|d |jtjdg d |jtjdt	ddd |j
tjdd |jtjdd |dd	 |j   |j   fd
d|j D }t|s_J | j|jg d |dd | j|jg d |dd | j|jg d |dd | j|jg dd |dd | j|jtj	ddtdd d S )Nr   r   )rQ   r   r   T)rs  Fr   g     @c                    r  r  r.   r   r  r.   r/   r   _  s    z2TestLogFormatter.test_sublabel.<locals>.<listcomp>r   i   P   rI   )r   rA   r`   r   r   rm   rm  )rp   rq   
set_xscalert   rB  r&   r   r{   r7   r9   rA  r  set_minor_formatterrr   r  r;  rC  r   r  r   )r)   rv   rw   show_major_labelsr.   r  r/   test_sublabelQ  s0   



 zTestLogFormatter.test_sublabelval)r   r   r   r   c                 C   s(   t  }t |_||t|ksJ d S r]  )r&   r  r\  r9  strr)   r  temp_lfr.   r.   r/   test_LogFormatter_callw  s   z'TestLogFormatter.test_LogFormatter_call)g       g       g       g       c                 C   s   t  }t |_|| d S r]  )r&   r  r\  r9  r  r.   r.   r/   test_LogFormatter_call_tiny~  s   z,TestLogFormatter.test_LogFormatter_call_tinyN)r.   )r4   r5   r6   pprint_datar<   r=   r>   r  r  rZ   r  r  r  r  r  r.   r.   r.   r/   r    s     




%
r  c                   @   s  e Zd Zedd Zejdg ddd Ze	dd e
d	d
D dd e
d	d
D  dg Zejdedd Zejdddd Zejdd	d	eeddd
   dd Zg dZejdedd Zdd Zdd Zdd  Zejd!d"d#d$ Zd%S )&TestLogitFormatterc                 C   s   t d| }|r@|d du}|d rt|d nd}|d dur&t|d nd}|d|  }|d s8|d dur@|r>d| S |S t d	| }|rYt|d
 t|d }}|| S td)z
        Parser to convert string as r'$\mathdefault{1.41\cdot10^{-4}}$' in
        float 1.41e-4, as '0.5' or as r'$\mathdefault{\frac{1}{2}}$' in float
        0.5,
        zT[^\d]*(?P<comp>1-)?(?P<mant>\d*\.?\d*)?(?:\\cdot)?(?:10\^\{(?P<expo>-?\d*)})?[^\d]*$compNmantr   expor   r   z4[^\d]*\\frac\{(?P<num>\d+)\}\{(?P<deno>\d+)\}[^\d]*$numdenozNot formatted by LogitFormatter)rer&  r  r   r   )stringr&  r  mantissar  rK  r  r  r.   r.   r/   logit_deformatter  s(   	z$TestLogitFormatter.logit_deformatterzfx, x))zSTUFF0.41OTHERSTUFFg=
ףp=?)zSTUFF1.41\cdot10^{-2}OTHERSTUFFg!u?)zSTUFF1-0.41OTHERSTUFFgzG?)z!STUFF1-1.41\cdot10^{-2}OTHERSTUFFgx$(~?)STUFFN)zSTUFF12.4e-3OTHERSTUFFNc                 C   s`   |d u r!t t t| W d    d S 1 sw   Y  d S t|}t||s.J d S r]  )r<   r   r   r  r  r   r   )r)   fxr   r   r.   r.   r/   test_logit_deformater  s   "
z(TestLogitFormatter.test_logit_deformaterc                 C   s   g | ]}d |  qS )r   r.   r   ir.   r.   r/   r     s    zTestLogitFormatter.<listcomp>r   r   c                 C   s   g | ]	}d d|   qS ra  r.   r  r.   r.   r/   r     rv  r   r   c                 C   s>   t jdd}|| j ||}t|}t||sJ dS )zj
        Test the formatted value correspond to the value for ideal ticks in
        logit space.
        Fuse_overlineN)r&   LogitFormatterr;  decade_testr  r  r   r   )r)   r   r*  sx2r.   r.   r/   r0     s
   
zTestLogitFormatter.test_basic)r   g      r   r   r   r   c                 C   s0   t jdd}|| j ||}|dksJ dS )zl
        Test that invalid value are formatted with empty string without
        raising exception.
        Fr  r}  N)r&   r  r;  r  )r)   r   r*  r  r.   r.   r/   test_invalid  s   zTestLogitFormatter.test_invalidrT   r   c                 C   s   t jdd}dD ]@}|d|  dk rH||d|  ||d|  g ||}||d|  }t|t| }d|  k rEd| k sHJ  J qdS )zS
        The format length should change depending on the neighbor labels.
        Fr  )	r   r   rj  r      r   i  i  r  r   r   r   N)r&   r  r;  r  r  )r)   r   r*  Nsxsx1dr.   r.   r/   test_variablelength  s     z&TestLogitFormatter.test_variablelength))Tr   )   F)K   F)Tr   )r  r  T)Tr   )r  Tr  )F)r   gRQ?gp=
ף?))r   Tr  r  zmethod, lims, casesc                 C   s   |rt jdd}|j| }nt|}t jdd}|D ]0\}}|| ||}	dd |	D }
|r?t|
dks>J ||fqt|
dksKJ ||fqdS )z,
        Test minor/major displays.
        Trn   c                 S      g | ]
}t |d kr|qS r   r}   r   fr.   r.   r/   r         z:TestLogitFormatter.test_minor_vs_major.<locals>.<listcomp>r   N)	r&   r   r(   r7   r8   r  set_minor_thresholdformat_ticksr}   )r)   methodr   casesmin_locr   min_form	threshold	has_minor	formattedlabelledr.   r.   r/   test_minor_vs_major  s   


z&TestLogitFormatter.test_minor_vs_majorc                 C   sd   t jdd}t jdd}|dd}dD ]}|| ||}dd |D }t||ks/J qdS )	z1
        Test the parameter minor_number
        Trn   ri   r   )r   r`   rI   r   c                 S   r  r   r  r  r.   r.   r/   r     r  z8TestLogitFormatter.test_minor_number.<locals>.<listcomp>N)r&   r   r  r(   set_minor_numberr  r}   )r)   r  r   r   minor_numberr  r  r.   r.   r/   test_minor_number  s   

z$TestLogitFormatter.test_minor_numberc                 C   s`   d}d}d}t jdd}|||ksJ |d |||ks!J |d |||ks.J dS )z1
        Test the parameter use_overline
        r  z$\mathdefault{1-10^{-2}}$z"$\mathdefault{\overline{10^{-2}}}$Fr  TN)r&   r  r  )r)   r   fx1fx2formr.   r.   r/   test_use_overline  s   

z$TestLogitFormatter.test_use_overlinec                 C   sP   t  }d|dv sJ |d d|dv sJ |d d|dv s&J dS )z-
        Test the parameter one_half
        z\frac{1}{2}r   z1/2zone halfN)r&   r  set_one_half)r)   r  r.   r.   r/   test_one_half   s   

z TestLogitFormatter.test_one_halfr  )r      i  c                 C   sv   t dd|dd }t }|D ]'}||}|dr(dt|dd   }nt|}t|| d| k s8J qd S )Nr   r   r   z1-r   )r7   rz   r&   r  r   
startswithr  abs)r)   r  ry  r  r   r  r  r.   r.   r/   test_format_data_short+  s   

z)TestLogitFormatter.test_format_data_shortN)r4   r5   r6   r   r  r<   r=   r>   r  r   r   r  r0   r  r7   exprz   r  lims_minor_majorr  r  r  r  r  r.   r.   r.   r/   r    s:    
 


&


r  c                   @   r   )TestFormatStrFormatterc                 C   s   t d}d|dksJ d S )Nz%05d00002r   )r&   FormatStrFormatter)r)   r/  r.   r.   r/   r0   9     
z!TestFormatStrFormatter.test_basicN)r4   r5   r6   r0   r.   r.   r.   r/   r  8  r   r  c                   @   s*   e Zd ZddgZejdedd ZdS )TestStrMethodFormatter)z{x:05d})r   r  )z{x:03d}-{pos:02d})r   r   z002-01zformat, input, expectedc                 C   s   t |}|| |ksJ d S r]  )r&   StrMethodFormatter)r)   formatinputr,   rN  r.   r.   r/   r0   E  r  z!TestStrMethodFormatter.test_basicN)r4   r5   r6   r  r<   r=   r>   r0   r.   r.   r.   r/   r  ?  s    r  c                   @   s*   e Zd Zg dZejdedd ZdS )TestEngFormatter))FEJ)z
-1.23457 k-1 kz-1.23 k)Tr  )u   −1.23457 k   −1 ku	   −1.23 k)FރB)z-1.23457r  z-1.23)Tr!  )u
   −1.23457r  u   −1.23)F_c97ݚ)z
-123.457 mz-123 mz	-123.46 m)Tr"  )u   −123.457 mu   −123 mu   −123.46 m)FQ^-':T)z
-1.23457 mz-1 mz-1.23 m)Tr#  )u   −1.23457 mu   −1 mu	   −1.23 m)Tg       rd  rd  z0.00Tr   r$  r%  )Tgm>)u
   1.23457 µu   1 µu   1.23 µ)Tg_c97ݚ?)z	123.457 mz123 mz123.46 m)Trj   )100 mr&  z100.00 m)Tr   )re  re  z1.00)TgރB?)z1.23457re  z1.23)Tg33333?@)z999.91 kz999.90)Tg*:?@r'  r'  1.00 k)F*:?)r  r  z-1.00 k)Tr*  )r   r   u	   −1.00 k)Tr   r(  )Ti  )z1.001 kr'  r)  )Ti )z	100.001 kz100 kz100.00 k)TgZ$.A)z	987.654 kz988 kz987.65 k)TguˏE)1230 Yr+  z	1230.00 Yzunicode_minus, input, expectedc                    s  |t jd< dd |}t tjddtjddf}t||D ]\}}|||ks+J q fdd|D }tjd	tjdd
tjdd
f}t||D ]\}}|||ksZJ qNdD ]c fdd|D }tjdtjddtjddf}t||D ]\}}|||ksJ qfdd|D }tjdtjddtjddf}t||D ]\}}|||ksJ qq]dS )a  
        Test the formatting of EngFormatter for various values of the 'places'
        argument, in several cases:

        0. without a unit symbol but with a (default) space separator;
        1. with both a unit symbol and a (default) space separator;
        2. with both a unit symbol and some non default separators;
        3. without a unit symbol but with some non default separators.

        Note that cases 2. and 3. are looped over several separator strings.
        r  r  
0123456789r   )placesr   c                 3   s0    | ]}|d   v r|d  n| V  qdS r    Nr.   r   _s)DIGITSUNITr.   r/   	<genexpr>  s    
z/TestEngFormatter.test_params.<locals>.<genexpr>)unit)r5  r-  )r}  u    z@_@c                 3   s8    | ]}|d   v r|  n| d V  qdS r.  replacer0  r2  r3  _sepr.   r/   r4    s    
)r5  r=  )r5  r-  r=  c                 3   s    | ]	}| d  V  qdS )r/  Nr6  r0  )r9  r.   r/   r4    s    )r=  )r-  r=  N)rp   r  r&   EngFormatterr   )r)   r"  r  r,   exp_outputs
formatters
_formatter_exp_outputr.   r8  r/   test_paramst  sL   




zTestEngFormatter.test_paramsN)r4   r5   r6   raw_format_datar<   r=   r>   r?  r.   r.   r.   r/   r  K  s    %r  c                  C   s   t  \} }|g dg d |g d tjddtjddfD ]}|j| | j	  dd |
 D }|g dksAJ q#d S )N)r   i  r   T)usetex)useMathTextc                 S   s   g | ]}|  qS r.   )get_text)r   lablr.   r.   r/   r     r   z8test_engformatter_usetex_useMathText.<locals>.<listcomp>)z$0$z$500$z$1$ k)rp   rq   plotry   r&   r:  rt   rA  rU  rV  get_xticklabels)rv   rw   r*  x_tick_label_textr.   r.   r/   $test_engformatter_usetex_useMathText  s   


rH  c                   @   sT   e Zd Zg dZg dZg dZejjdeeddd Z	ejded	d
 Z
dS )TestPercentFormatter))r   r   %r  r   z120%)r   r   rJ  r   Z   z100%)r   r   rJ  rK  rj  z90%)r   r   rJ  g333333(   z-2%)r   r   rJ  g     V@r   z90.0%)r   r   rJ  gfffffT@rK  z80.1%)r   r   rJ  gQQ@rj  z70.2%)r   r   rJ  gxFNrL  z-60.6%)r   NrJ  _   r   z95.00%)r   NrJ  rA   r   z300%)      1@NrJ  r   g      !@z6%)rN  NrJ  r   g @z5.9%)r   NrJ  igư>z-2000.00000%)r   r   Nr  r   z120.00)r  rA   r}  rj  r   z66.667)rl  Nz
^^Foobar$$   rk  z50.0^^Foobar$$)zdecimals=0, x>100%zdecimals=0, x=100%zdecimals=0, x<100%zdecimals=0, x<0%zdecimals=1, x>100%zdecimals=1, x=100%zdecimals=1, x<100%zdecimals=1, x<0%z$autodecimal, x<100%, display_range=1z7autodecimal, x>100%, display_range=6 (custom xmax test)z;autodecimal, x<100%, display_range=8.5 (autodecimal test 1)z;autodecimal, x<100%, display_range=8.4 (autodecimal test 2)z=autodecimal, x<-100%, display_range=1e-6 (tiny display range)zNone as percent symbolzEmpty percent symbolzCustom percent symbol))FF50\{t}%)FTz50\\\{t\}\%)TFrP  )TTrP  z2xmax, decimals, symbol, x, display_range, expected)idsc                 C   sX   t |||}tjddid ||||ksJ W d    d S 1 s%w   Y  d S )Nr  Frcr&   PercentFormatterrZ   r[   
format_pct)r)   xmaxdecimalssymbolr   display_ranger,   r*  r.   r.   r/   r0     s   "zTestPercentFormatter.test_basiczis_latex, usetex, expectedc                 C   sX   t jd|d}tjd|id |dd|ksJ W d    d S 1 s%w   Y  d S )Nz\{t}%)rY  is_latexr  rR  rj  r   rT  )r)   r[  rA  r,   rN  r.   r.   r/   
test_latex  s   "zTestPercentFormatter.test_latexN)r4   r5   r6   percent_datapercent_ids
latex_datar<   r=   r>   r0   r\  r.   r.   r.   r/   rI    s    
rI  c                  C   L   t  \} }tt |jt  W d    d S 1 sw   Y  d S r]  )	rp   rq   r<   r   	TypeErrorrt   rA  r&   r   rv   rw   r.   r.   r/   test_majformatter_type     "rc  c                  C   r`  r]  )	rp   rq   r<   r   ra  rt   r  r&   r   rb  r.   r.   r/   test_minformatter_type  rd  re  c                  C   r`  r]  )	rp   rq   r<   r   ra  rt   rB  r&   r  rb  r.   r.   r/   test_majlocator_type  rd  rf  c                  C   r`  r]  )	rp   rq   r<   r   ra  rt   r{   r&   r  rb  r.   r.   r/   test_minlocator_type!  rd  rg  c                     sH   t    fdd} | ddd | ddd | ddd | ddd d S )	Nc                    s|   | |d}t j|d  dd|}W d    n1 sw   Y  t|j dk| ks/J t|j dk|ks<J d S )N)zxtick.minor.visiblezytick.minor.visiblerR  r   r   )rp   r[   add_subplotr}   rt   get_minor_ticksr   )xminoryminorr  rS  rw   rv   r.   r/   minorticksubplot*  s   z,test_minorticks_rc.<locals>.minorticksubplotFr   Tr   rA   r`   )rp   figure)rm  r.   rl  r/   test_minorticks_rc'  s   	ro  z%remove_overlapping_locs, expected_num))Tr   )Nr   )Fr   c                 C   sB  t jdddd}t t|}t \}}||| |jt	j
  |jt	j
d |jt	j
d |jt	j
d |jd | d urP| |j_|jj}||j ks]J tj|j|d	 |jj}||jjksqJ t|j |ks|J t|j |ksJ t|j |ksJ t|j |d
 ksJ d S )Nz
2018-11-03z
2018-11-06
datetime64rm  z
%a)r   r   rk     z%H:%Mr   )remove_overlapping_locsr   )r7   r9   onesr}   rp   rq   rE  rt   rB  rZ   dates
DayLocatorrA  DateFormatterr{   HourLocatorr  ri  rr  get_remove_overlapping_locssetpr~   get_minorticklabelsget_minorticklines)rr  expected_numtr   rv   rw   currentnewr.   r.   r/   test_remove_overlap9  s(   r  subhiaardvark)r   r   c                 C   sB   t  }tt ||  W d    d S 1 sw   Y  d S r]  )r&   r   r<   r   r   r   )r  llr.   r.   r/   test_bad_locator_subs^  s   "r  rC   )r   r   rA   r   r  c              	   C   sR   t  }|j| d dD ]}|d|}tt|dddk s&J qd S )NrB   )r   r   r      r   rj  r   r   r   r      r   )r&   r   rK   r(   r7   diffr   r   )rC   r  topr   r.   r.   r/   test_small_range_loglocatorg  s   &r  )7
contextlibr   r   r3  r  numpyr7   numpy.testingr   r   r<   
matplotlibrZ   matplotlib.pyplotpyplotrp   matplotlib.tickertickerr&   r   r?   rN   rf   r   r   r   r   r   r  r  r  r\  rc  r  r  r  r  r  r  r  rH  rI  rc  re  rf  rg  ro  r=   r>   r  zerosr  r  r  r  r.   r.   r.   r/   <module>   sl    "g&  !
! N 3qE
!

