o
    g                     @   sF  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 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(G d/d0 d0Z)d1d2 Z*G d3d4 d4Z+d5d6 Z,d7d8 Z-d9d: Z.d;d< Z/d=d> Z0e
j12d?d@dAdB Z3e
j12dCdDdEge4dFgdGdH Z5e
j12dIg dJe
j16dKdLdM Z7dS )N    )nullcontextN)assert_almost_equalassert_array_equal)_apic                
   @   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/   Z/home/ubuntu/cloudmapper/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,   r3   r-   r.   r/   r/   r0   test_integer$   s   zTestMaxNLocator.test_integer)__name__
__module____qualname__nparrayarange
basic_datainteger_datapytestmarkparametrizer1   r4   r/   r/   r/   r0   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ӿ皙?rE   rF   )r'   LinearLocatorr8   r9   r   r)   r*   r.   
test_valuer/   r/   r0   r1   +   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   rC      )r   r   )rD   presetsN)r'   rG   
set_paramsrD   rK   r*   r.   r/   r/   r0   test_set_params0   s   z!TestLinearLocator.test_set_paramsN)r5   r6   r7   r1   rN   r/   r/   r/   r0   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   rA   )NV-	@base)go"V-gV-	r   rP   V-@go"@gV-)@r   )r'   MultipleLocatorr8   r9   r   r)   rH   r/   r/   r0   r1   <   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datarP   rQ   r   r   )r   r   Nmpl
rc_contextr'   rV   r   view_limitsrM   r/   r/   r0   test_view_limitsB   s   "z$TestMultipleLocator.test_view_limitsc                 C   rW   )	zb
        Test that everything works properly with 'round_numbers' for auto
        limit.
        rX   round_numbersrP   rQ      )rS   rT   NrZ   rM   r/   r/   r0   test_view_limits_round_numbersJ   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?rQ   g333333?N)r'   rV   rL   _edgestep)r*   multr/   r/   r0   rN   S   s   z#TestMultipleLocator.test_set_paramsN)r5   r6   r7   r1   r^   rb   rN   r/   r/   r/   r0   rO   ;   s
    	rO   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?rc   r   g333333??r   g?r   gffffff?g      ?g?g?Tminor)	pltsubplotsset_xlimminorticks_onr8   r9   r   xaxisget_ticklocs)r*   figaxrI   r/   r/   r0   r1   ^   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   )rq   rr   rs   
set_xticksr8   linspacert   ru   set_minor_locatorr'   AutoMinorLocatorlenget_minorticklocs)r*   nb_majorticksexpected_nb_minorticksrw   rx   xlimsr/   r/   r0   test_low_number_of_majorticksm   s   
z2TestAutoMinorLocator.test_low_number_of_majorticks))r   r   )r   ra   )      @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/   r0   
<listcomp>       zKTestAutoMinorLocator.test_using_all_default_major_steps.<locals>.<listcomp>)	r[   r\   majorstep_minordivisionsr8   testingassert_allcloser'   AutoLocator_steps)r*   
majorstepsr/   r/   r0   "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   )rq   rr   rs   rz   rt   ru   r|   r'   r}   r~   r   )r*   
major_stepexpected_nb_minordivisionsrw   rx   r   nb_minor_divisionsr/   r/   r0   test_number_of_minor_ticks   s   

z/TestAutoMinorLocator.test_number_of_minor_ticks))r   rh   )r   gn?)r   ԍ;)r   gVs?=)gH׊gIhG|a)gv!>ҷ>)ʔA{v()g"s2_dglEՎfUri   ){Gzt?{Gz?Q?g?gQ?gQ?g
ףp=
?rj   g)\(?gp=
ף?gQ?g333333?g(\µ?g
ףp=
?gRQ?gzG?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 )
NTrp   yr   )	linewidthmajork)colorr   ro   )rq   rr   rt   gridset_ylimr   yaxisrv   )r*   limrefrw   rx   r/   r/   r0   test_additional   s   
z$TestAutoMinorLocator.test_additionalN)r5   r6   r7   r1   paramsr=   r>   r?   r   r   r   r   limits	referencelistzipadditional_datar   r/   r/   r/   r0   rg   ]   s4    

rg   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   rC   r     )h㈵>r   rk         $@     @@     j@g    cA    eAr   g     @r   rQ   )
r   r          @      @g       @g      0@g      @@g      P@g      `@g      p@r   r   )	r'   
LogLocatorr=   raises
ValueErrorr)   r8   r9   r   rH   r/   r/   r0   r1      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subsrl   rm   )g)\(?gq=
ףp?gQ?r   gp=
ף?gHzG?gQ?r   r   r   rn   r	   r   )r'   r   r   r)   r8   r:   rM   r/   r/   r0   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.
           rJ   r   ra   )rD   numdecsr   rR   N)r'   r   rL   rD   r   _baser   _subsrM   r/   r/   r0   rN      s   zTestLogLocator.test_set_paramsN)r5   r6   r7   r1   r   rN   r/   r/   r/   r0   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UserWarningrL   rM   r/   r/   r0   rN      s   
"zTestNullLocator.test_set_paramsNr5   r6   r7   rN   r/   r/   r/   r0   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)r8   iscloselog)r   r   r/   r/   r0   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   )r8   r9   r   r   r   )r   r   rx   aylxlyr/   r/   r0   r      s   

  z _LogitHelper.assert_almost_equalN)r5   r6   r7   staticmethodr   r   r/   r/   r/   r0   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)rj   r   )r   gףp=
?)gMb@?gCl?-C6
?gSt$?)gh㈵>g;?)gƠ>g?gHj>ge(?)g:0y5>g$P?r   r   rB   ra   r   r   r   rJ   	   ))g?g333333?)rj   rF   )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/   r0   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%   r3   )ra   rJ      N)r'   r   r(   rL   r)   shaper   )r*   r   r.   maxn_locr%   ticks
maxn_ticksr/   r/   r0   test_maxn_major0  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)
intr8   floorlog10r'   r   rangerL   r~   r)   )r*   r   basic_neededr.   r%   r/   r/   r0   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%   rp   r   r   r   N)	r   r~   r'   r   r   rL   r)   r   r   )
r*   r   r   r   r   r.   	minor_locr%   major_ticksminor_ticksr/   r/   r0   
test_minorL  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$   TFro   )r'   r   rp   rL   rM   r/   r/   r0   test_minor_attri  s   

z TestLogitLocator.test_minor_attrr   r   c                 C   s    g | ]\}}||kr||fqS r/   r/   )r   abr/   r/   r0   r   x  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/   r0   test_nonsingular_okv  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/   r0   test_nonsingular_nok  s   

 z%TestLogitLocator.test_nonsingular_nokN)r5   r6   r7   ref_basic_limitsr8   r:   ref_basic_major_ticksref_maxn_limitsr=   r>   r?   r   r   r   r   r   r   acceptable_vmin_vmax	itertoolsproductr   r   r/   r/   r/   r0   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   rL   r%   )r*   fixedr/   r/   r0   rN     s   z TestFixedLocator.test_set_paramsNr   r/   r/   r/   r0   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.
        rB   ra   )rR   offsetr   N)r'   IndexLocatorrL   r   r  )r*   indexr/   r/   r0   rN     s   z TestIndexLocator.test_set_paramsNr   r/   r/   r/   r0   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   )rR   	linthreshr   rJ   )r   rD   N)r'   SymmetricalLogLocatorrL   r   rD   )r*   symr/   r/   r0   rN     s   z)TestSymmetricalLogLocator.test_set_paramsNr   r/   r/   r/   r0   r    r   r  c                   @   s&   e Zd Zejdg ddd ZdS )TestIndexFormatterzx, label)) )r   label0)r   r  )r   label1)r   r  )r   label2)r   r  )r   r  c                 C   sJ   t   tg d}W d    n1 sw   Y  |||ks#J d S )N)r  r  r  )r   'suppress_matplotlib_deprecation_warningr'   IndexFormatter)r*   r   label	formatterr/   r/   r0   test_formatting  s   
	z"TestIndexFormatter.test_formattingN)r5   r6   r7   r=   r>   r?   r  r/   r/   r/   r0   r    s    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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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?rl   )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)	)Fry   )r   r	   r   F)Tr  r   )ir   r   F)Tr  )ir   r   F)Tr  )ix   r   F)Tr  )in   r   F)Tr  )gMbPgMb`?r   F)T)rU   r   )g   tAg   0Ar   T)Try   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.300zunicode_minus, result)T   −1)F-1c                 C   s.   |t jd< t j d |ksJ d S )Naxes.unicode_minusr   )r[   rcParamsrq   gcaru   get_major_formatterformat_data_shortstrip)r*   unicode_minusresultr/   r/   r0   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)rq   rr   ru   r'  r=   r   r   r   rs   _update_ticksr  )r*   leftrightr  rw   rx   r  r/   r/   r0   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)r[   r\   r'   ScalarFormatterget_useOffset)r*   r2  tmp_formr/   r/   r0   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 |
  |dd |g d	 ||d
v sHJ W d    d S 1 sSw   Y  d S )Nthousands_sepgroupingr   zLocale does not apply groupingzaxes.formatter.use_localeTr   r   )r   r   rB   r   )locale
localeconvCHAR_MAXr=   skipr[   r\   r'   r3  get_useLocalecreate_dummy_axis
set_boundsset_locs)r*   convsepr5  r/   r/   r0   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 )Nra   )r'   r3  set_scientificset_powerlimitsrq   rr   r   set_major_formatterr   set_major_locatorr(   r@  get_majorticklocsorderOfMagnitude)	r*   sci_type	scilimitsr   
orderOfMagfewticksr5  rw   rx   r/   r/   r0   test_scilimits5  s   


z"TestScalarFormatter.test_scilimitszdata, expectedc                 C   s8   t  \}}|dd |j j}|||ksJ d S )Nr   r   )rq   rr   rs   ru   r'  r(  )r*   rY   r-   rw   rx   fmtr/   r/   r0   test_cursor_precisionD  s   z)TestScalarFormatter.test_cursor_precisionc                 C   s6   t  }|  |dd |j}|||ksJ d S )Nr   r   )r'   r3  r>  r?  r(  )r*   rY   r-   sfrO  r/   r/   r0   test_cursor_dummy_axisK  s
   z*TestScalarFormatter.test_cursor_dummy_axisN)r5   r6   r7   offset_datause_offset_datascilimits_datacursor_datar=   r>   r?   r,  r1  r6  rC  rN  rP  rR  r/   r/   r/   r0   r    s6    !




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/   r0   __init__W  s   
zFakeAxis.__init__c                 C   s   | j | jfS rX  rY  )r*   r/   r/   r0   get_view_interval[  s   zFakeAxis.get_view_intervalNr   r   )r5   r6   r7   __doc__rZ  r[  r/   r/   r/   r0   rW  U  s    
rW  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 )TestLogFormatterExponentTra   r   r   )z-3z-2r#  0123Fr   rk   r   rF   gɿgh㈵r   )0.1z1e-053.14z0.2z-0.2z-1e-052   )rB   r      *   dtype)rb  51242r   g      @r   z2labelOnlyBase, exponent, locs, positions, expectedrR   c           	         sN   t j||d td||  _|| } fddt||D }||ks%J d S )NrR   labelOnlyBaser   c                    s   g | ]	\}} ||qS r/   r/   )r   r   posr  r/   r0   r   v      z7TestLogFormatterExponent.test_basic.<locals>.<listcomp>)r'   LogFormatterExponentrW  axisr   )	r*   rn  rR   exponentlocs	positionsr-   valslabelsr/   rp  r0   r1   m  s   z#TestLogFormatterExponent.test_basicc                 C   s*   t jddd}t |_|ddksJ d S )Nr   Trm  g&$?r  )r'   rr  rW  rs  )r*   r  r/   r/   r0   
test_blanky  s   z#TestLogFormatterExponent.test_blankN)r5   r6   r7   r8   r:   r9   pir   float
param_datae	base_datar=   r>   r?   r1   ry  r/   r/   r/   r0   r^  _  s$    	r^  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}}$)rB   r   z$\mathdefault{1}$)rB   r   z$\mathdefault{0.01}$)rB   r
   z$\mathdefault{100}$)rB   r   z$\mathdefault{10^{-3}}$)rB   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)r[   r\   rO  )r*   min_exponentvaluer-   r/   r/   r0   test_min_exponent  s   "z*TestLogFormatterMathtext.test_min_exponentN)r5   r6   r7   r'   LogFormatterMathtextrO  	test_datar=   r>   r?   r  r/   r/   r/   r0   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 )NrQ   >   r  r   r   r   text.usetexF)r'   LogFormatterSciNotationsublabelr[   r\   )r*   rR   r  r-   r  r/   r/   r0   r1     s
   
"z&TestLogFormatterSciNotation.test_basicN)	r5   r6   r7   r  r=   r>   styler?   r1   r/   r/   r/   r0   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)rk   r   1e-1)r   r   r`  )r   r   10)r   r   100)r   r   1000)'  r   1e4)r  r   1e5)r  r   r_  )r  r   r_  )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   r_  )r   r   r_  )r   r   0.001)r   r   0.01)rk   r   rc  )r   r   r`  )r   r   r  )r   r   r  )r   r   r  )r  r   10000)r  r   100000)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   r  )r  r   r  )r   r   r_  )r   r   r_  )r   r   r  )r   r   r  )rk   r   rc  )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   z0.03)r  r   z0.31)r  r   rd  )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   r_  )r   r   r_  )r   r   r_  )r   r   r  )rk   r   rc  )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   r_  )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   r_  )r   r   r_  )r   r   r_  )r   r   r_  )rk   r   rc  )r   r   r`  )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  )rk   r  r  )r   r  r`  )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 rX  )r'   LogFormatter_pprint_val)r*   r  domainr-   rO  r  r/   r/   r0   test_pprint8  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/   r0   r   D      z0TestLogFormatter._sub_labels.<locals>.<listcomp>c                       g | ]} |d kqS r  r/   r   rO  r/   r0   r   E  r  N)get_minor_formatterr   r@  r8   r   r   )r*   rs  r   minor_tlocscoefslabel_expected
label_testr/   )rO  r   r0   _sub_labels>  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   )rR   r   r   T)rn  Fr   g     @c                    r  r  r/   r   r  r/   r0   r   V  s    z2TestLogFormatter.test_sublabel.<locals>.<listcomp>r   i   P   rJ   )r   rB   ra   r   r   rn   rh  )rq   rr   
set_xscaleru   rG  r'   r   r|   r8   r:   rF  r  set_minor_formatterrs   r'  r@  rH  r   r  r   )r*   rw   rx   show_major_labelsr/   r  r0   test_sublabelH  s0   



 zTestLogFormatter.test_sublabelval)r   r   r   r   c                 C   s(   t  }t |_||t|ksJ d S rX  )r'   r  rW  rs  strr*   r  temp_lfr/   r/   r0   test_LogFormatter_calln  s   z'TestLogFormatter.test_LogFormatter_call)g       g       g       g       c                 C   s   t  }t |_|| d S rX  )r'   r  rW  rs  r  r/   r/   r0   test_LogFormatter_call_tinyu  s   z,TestLogFormatter.test_LogFormatter_call_tinyN)r/   )r5   r6   r7   pprint_datar=   r>   r?   r  r  r  r  r  r  r/   r/   r/   r0   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  r  r  r  r/   r/   r0   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 rX  )r=   r   r   r  r  r   r   )r*   fxr   r   r/   r/   r0   test_logit_deformater  s   "
z(TestLogitFormatter.test_logit_deformaterc                 C   s   g | ]}d |  qS )r   r/   r   ir/   r/   r0   r     s    zTestLogitFormatter.<listcomp>r   r   c                 C   s   g | ]	}d d|   qS r\  r/   r  r/   r/   r0   r     rq  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/   r0   r1     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/   r0   test_invalid  s   zTestLogitFormatter.test_invalidrU   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   re  r      r   i  i  r  r   r   r   N)r'   r  r@  r  r  )r*   r   r  Nsxsx1dr/   r/   r0   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.
        Tro   c                 S      g | ]
}t |d kr|qS r   r~   r   fr/   r/   r0   r         z:TestLogitFormatter.test_minor_vs_major.<locals>.<listcomp>r   N)	r'   r   r)   r8   r9   r  set_minor_thresholdformat_ticksr~   )r*   methodr   casesmin_locr   min_form	threshold	has_minor	formattedlabelledr/   r/   r0   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
        Tro   rj   r   )r   ra   rJ   r   c                 S   r  r   r  r  r/   r/   r0   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/   r0   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/   r0   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/   r0   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   )r8   r{   r'   r  r(  
startswithr{  abs)r*   r  ru  r  r   r  r  r/   r/   r0   test_format_data_short"  s   

z)TestLogitFormatter.test_format_data_shortN)r5   r6   r7   r   r  r=   r>   r?   r  r   r   r  r1   r  r8   expr{   r  lims_minor_majorr   r  r  r	  r  r/   r/   r/   r0   r  }  s:    
 


&


r  c                   @   r   )TestFormatStrFormatterc                 C   s   t d}d|dksJ d S )Nz%05d00002r   )r'   FormatStrFormatter)r*   r5  r/   r/   r0   r1   0     
z!TestFormatStrFormatter.test_basicN)r5   r6   r7   r1   r/   r/   r/   r0   r  /  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 rX  )r'   StrMethodFormatter)r*   formatinputr-   rO  r/   r/   r0   r1   <  r  z!TestStrMethodFormatter.test_basicN)r5   r6   r7   r  r=   r>   r?   r1   r/   r/   r/   r0   r  6  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       r_  r_  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)Trk   )100 mr!  z100.00 m)Tr   )r`  r`  z1.00)TgރB?)z1.23457r`  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/   r0   	<genexpr>  s    
z/TestEngFormatter.test_params.<locals>.<genexpr>)unit)r0  r(  )r  u    z@_@c                 3   s8    | ]}|d   v r|  n| d V  qdS r)  replacer+  r-  r.  _sepr/   r0   r/    s    
)r0  rB  )r0  r(  rB  c                 3   s    | ]	}| d  V  qdS )r*  Nr1  r+  )r4  r/   r0   r/    s    )rB  )r(  rB  N)rq   r%  r'   EngFormatterr   )r*   r*  r  r-   exp_outputs
formatters
_formatter_exp_outputr/   r3  r0   test_paramsk  sL   




zTestEngFormatter.test_paramsN)r5   r6   r7   raw_format_datar=   r>   r?   r:  r/   r/   r/   r0   r  B  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/   r0   r     r   z8test_engformatter_usetex_useMathText.<locals>.<listcomp>)z$0$z$500$z$1$ k)rq   rr   plotrz   r'   r5  ru   rF  canvasdrawget_xticklabels)rw   rx   r  x_tick_label_textr/   r/   r0   $test_engformatter_usetex_useMathText  s   


rE  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   rG  r   Z   z100%)r   r   rG  rH  re  z90%)r   r   rG  g333333(   z-2%)r   r   rG  g     V@r   z90.0%)r   r   rG  gfffffT@rH  z80.1%)r   r   rG  gQQ@re  z70.2%)r   r   rG  gxFNrI  z-60.6%)r   NrG  _   r   z95.00%)r   NrG  rB   r   z300%)      1@NrG  r   g      !@z6%)rK  NrG  r   g @z5.9%)r   NrG  igư>z-2000.00000%)r   r   Nr  r   z120.00)r  rB   r  re  r   z66.667)rg  Nz
^^Foobar$$   rf  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\}\%)TFrM  )TTrM  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'   PercentFormatterr[   r\   
format_pct)r*   xmaxdecimalssymbolr   display_ranger-   r  r/   r/   r0   r1     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}%)rV  is_latexr  rO  re  r   rQ  )r*   rX  r<  r-   rO  r/   r/   r0   
test_latex  s   "zTestPercentFormatter.test_latexN)r5   r6   r7   percent_datapercent_ids
latex_datar=   r>   r?   r1   rY  r/   r/   r/   r0   rF    s    
rF  c                  C   L   t  \} }tt |jt  W d    d S 1 sw   Y  d S rX  )	rq   rr   r=   r   	TypeErrorru   rF  r'   r   rw   rx   r/   r/   r0   test_majformatter_type     "r`  c                  C   r]  rX  )	rq   rr   r=   r   r^  ru   r  r'   r   r_  r/   r/   r0   test_minformatter_type  ra  rb  c                  C   r]  rX  )	rq   rr   r=   r   r^  ru   rG  r'   r  r_  r/   r/   r0   test_majlocator_type  ra  rc  c                  C   r]  rX  )	rq   rr   r=   r   r^  ru   r|   r'   r  r_  r/   r/   r0   test_minlocator_type  ra  rd  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.visiblerO  r   r   )rq   r\   add_subplotr~   ru   get_minor_ticksr   )xminoryminorr  rP  rx   rw   r/   r0   minorticksubplot!  s   z,test_minorticks_rc.<locals>.minorticksubplotFr   Tr   rB   ra   )rq   figure)rj  r/   ri  r0   test_minorticks_rc  s   	rl  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
datetime64rh  z
%a)r   r   rf     z%H:%Mr    )remove_overlapping_locsr   )r8   r:   onesr~   rq   rr   r@  ru   rG  r[   dates
DayLocatorrF  DateFormatterr|   HourLocatorr  rf  ro  get_remove_overlapping_locssetpr   get_minorticklabelsget_minorticklines)ro  expected_numtr   rw   rx   currentnewr/   r/   r0   test_remove_overlap0  s(   r}  subhiaardvark)r   r   c                 C   sB   t  }tt ||  W d    d S 1 sw   Y  d S rX  )r'   r   r=   r   r   r   )r~  llr/   r/   r0   test_bad_locator_subsU  s   "r  rD   )r   r   rB   r   r  c              	   C   sR   t  }|j| d dD ]}|d|}tt|dddk s&J qd S )NrC   )r   r   r      r    re  r   r   r   r      r   )r'   r   rL   r)   r8   diffr   r   )rD   r  topr   r/   r/   r0   test_small_range_loglocator^  s   &r  )8
contextlibr   r   r9  r  numpyr8   numpy.testingr   r   r=   
matplotlibr[   r   matplotlib.pyplotpyplotrq   matplotlib.tickertickerr'   r   r@   rO   rg   r   r   r   r   r   r  r  r  r  rW  r^  r  r  r  r  r  r  r  rE  rF  r`  rb  rc  rd  rl  r>   r?   r}  zerosr  r  r  r/   r/   r/   r0   <module>   sp    "g&  
! N 3qE
!

