o
    ‘iµ;  ã                   @   sL  d dl Zd dlmZ d dlZd dlZd dlmZ d dl	m
Z
mZ e
dgdddd	d
„ ƒZe
dgdddddd„ ƒZe
dgƒdd„ ƒZdd„ Zeƒ dd„ ƒZeƒ dd„ ƒZeƒ dd„ ƒZe
dgdddd„ ƒZe
dgddd d!„ ƒZe
d"gddd#d$„ ƒZe
d%gddd&d'„ ƒZe
d(gddd)d*„ ƒZe
d+gddd,d-„ ƒZe
d.gddd/d0„ ƒZe
d1gddd2d3„ ƒZed4gd5d6d7„ ƒZed4gd5d8d9„ ƒZd:d;„ Zd<d=„ Zd>d?„ Zd@dA„ Z dBdC„ Z!dDdE„ Z"ed4gd5dFdG„ ƒZ#ed4gd5dHdI„ ƒZ$dJdK„ Z%dLdM„ Z&dNdO„ Z'dPdQ„ Z(ed4gd5dRdS„ ƒZ)dTdU„ Z*dVdW„ Z+dXdY„ Z,e
dZgddd[d\„ ƒZ-dS )]é    N)Úassert_allclose)Úpyplot)Úimage_comparisonÚcheck_figures_equalZ
polar_axesÚdefaultgú~j¼t“ˆ?)ÚstyleÚtolc               	   C   sº   t  ddd¡} dt j |  }t ¡ }|jdd}|j|| ddd	\}|jd
dddd	\}d}| | || }}| |g|gd¡ |jd||fddtdddddd |j	ddddd d S )Nç        ç      ð?çü©ñÒMbP?ç      @T©Úpolarz#ee8d18é   )ÚcolorZlw©r   r   ©r   é   z#0000ffr   é   Úoza polar annotation)çš™™™™™©?r   zfigure fractionÚblackr   ©Ú	facecolorÚshrinkÚleftÚbaseline)ÚxyÚxytextÚ
textcoordsÚ
arrowpropsÚhorizontalalignmentÚverticalalignmentÚxÚout)ZaxisÚtick1OnÚtick2OnÚ	direction)
ÚnpÚarangeÚpiÚpltÚfigureÚadd_subplotÚplotÚannotateÚdictÚtick_params)ÚrÚthetaÚfigÚaxÚlineÚindZthisrZ	thistheta© r8   új/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/matplotlib/tests/test_polar.pyÚtest_polar_annotations
   s$   
ú	r:   Zpolar_coordsT)r   Zremove_textr   c                  C   s”   t jjdddddd} t ¡ }|jdd}| | ¡ |  |j¡ |j	d	t
jd
 dft
jd dfddtddddddd	 | dd¡ | dd¡ d S )Nr   é
   é   r2   ç      à?)r   ÚalphaÚequal)Zaspectzthe topç       @ç      $@r   g      4@r   r   r   r   r   r   T)r   r   Zxycoordsr   r    r!   r"   Zclip_oniìÿÿÿ)ÚmplZpatchesZEllipser+   r,   r-   Z
add_artistZset_clip_boxZbboxr/   r(   r*   r0   Zset_xlimÚset_ylim)Úelr4   r5   r8   r8   r9   Útest_polar_coord_annotations,   s"   

ørE   zpolar_alignment.pngc                  C   sŠ   t  ddd¡} g d¢}t ¡ }g d¢}|j|ddd}| | ¡ |j|dd	d}|j d
¡ tdƒD ]}|j	| j
|| | ddd q2d S )Nr   ih  éZ   )r   çš™™™™™É?çš™™™™™Ù?g333333ã?çš™™™™™é?r   ©çš™™™™™¹?rK   rI   rI   TÚ
horizontal)r   ÚlabelÚverticalFé   r   Útop)Zangler!   r"   )r(   r)   r+   r,   Úadd_axesZset_thetagridsÚpatchZset_visibleÚrangeÚaxesZ
set_rgrids)ZanglesZgrid_valuesr4   ÚrectrL   rN   Úir8   r8   r9   Útest_polar_alignmentI   s   

þÿrW   c                  C   sJ   t  ¡ } t  ddgddg¡ t  ddgddg¡ t| jƒdks#J d	ƒ‚d S )
Nr   rO   rK   rG   r   é   g333333Ó?rH   z!More than one polar axes created.)r+   r,   r   ÚlenrT   )r4   r8   r8   r9   Útest_polar_twice^   s   rZ   c                 C   s„   | j dd}| t ddg¡ddg¡ | t ddg¡ddg¡ |j dd}| t dd	g¡ddg¡ | t dd
g¡ddg¡ d S )Nr   ©Ú
projectioné³   iMÿÿÿrG   rK   rO   éþÿÿÿéµ   if  )r-   r.   r(   Údeg2rad©Úfig_testÚfig_refr5   r8   r8   r9   Útest_polar_wrape   s   rd   c                    s~   dd l m  m‰  ˆ  ¡  g d¢}g d¢}t | j¡ t ‡ fdd„|D ƒ|¡ |jdd}| 	t
 |¡|¡ |jdd	 d S )
Nr   ©g      >@g     €F@g      N@ç     €V@©r
   r@   ç      @r   c                    ó   g | ]}|ˆ j  ‘qS r8   ©Údeg©Ú.0r#   ©Zunitsr8   r9   Ú
<listcomp>w   ó    z&test_polar_units_1.<locals>.<listcomp>r   r[   rk   )Úxlabel)Úmatplotlib.testing.jpl_unitsÚtestingÚ	jpl_unitsÚregisterr+   r,   Únumberr   r-   r.   r(   r`   Úset)rb   rc   ÚxsÚysr5   r8   rn   r9   Útest_polar_units_1o   s   rz   c                    sÌ   dd l m  m‰  ˆ  ¡  g d¢}‡ fdd„|D ƒ}g d¢}‡ fdd„|D ƒ}t | j¡ tj||ddd	 tt 	¡ j
 ¡ ˆ jƒsCJ ‚|jd
d}| t |¡|¡ |j
 tj dj¡¡ |jddd d S )Nr   re   c                    ri   r8   rj   rl   rn   r8   r9   ro   ƒ   rp   z&test_polar_units_2.<locals>.<listcomp>rg   c                    ri   r8   )Úkm)rm   Úyrn   r8   r9   ro   …   rp   Zradr{   )Z
thetaunitsZrunitsr   r[   z{:.12})rq   Zylabel)rr   rs   rt   ru   r+   r,   rv   r   Ú
isinstanceÚgcaÚxaxisZget_major_formatterZUnitDblFormatterr-   r.   r(   r`   Zset_major_formatterrB   ZtickerZFuncFormatterÚformatrw   )rb   rc   rx   Zxs_degry   Zys_kmr5   r8   rn   r9   Útest_polar_units_2~   s   ÿr   Z
polar_rmin)r   c                  C   sZ   t  ddd¡} dt j |  }t ¡ }|jg d¢dd}| || ¡ | d¡ | d	¡ d S )
Nr   rh   ç{®Gáz„?rO   rJ   Tr   r@   r=   ©	r(   r)   r*   r+   r,   rQ   r.   Úset_rmaxÚset_rmin©r2   r3   r4   r5   r8   r8   r9   Útest_polar_rmin“   ó   
r‡   Zpolar_negative_rminc                  C   sZ   t  ddd¡} dt j |  }t ¡ }|jg d¢dd}| || ¡ | d¡ | d¡ d S )Ng      Àr	   r‚   rO   rJ   Tr   rƒ   r†   r8   r8   r9   Útest_polar_negative_rminŸ   rˆ   r‰   Zpolar_roriginc                  C   sd   t  ddd¡} dt j |  }t ¡ }|jg d¢dd}| || ¡ | d¡ | d	¡ | 	d
¡ d S )Nr   rh   r‚   rO   rJ   Tr   r@   r=   r	   )
r(   r)   r*   r+   r,   rQ   r.   r„   r…   Úset_roriginr†   r8   r8   r9   Útest_polar_rorigin«   s   

r‹   zpolar_invertedylim.pngc                  C   s*   t  ¡ } | jg d¢dd}| dd¡ d S )NrJ   Tr   rO   r   )r+   r,   rQ   rC   ©r4   r5   r8   r8   r9   Útest_polar_invertedylim¸   s   r   zpolar_invertedylim_rorigin.pngc                  C   sV   t  ¡ } | jg d¢dd}|j d¡ |jddgddgdd | d¡ | d¡ d S )	NrJ   Tr   r   rO   Únone)Úcr   )r+   r,   rQ   ÚyaxisZset_invertedr.   ZmarginsrŠ   rŒ   r8   r8   r9   Útest_polar_invertedylim_rorigin¿   s   
r‘   Zpolar_theta_positionc                  C   s\   t  ddd¡} dt j |  }t ¡ }|jg d¢dd}| || ¡ | dd	¡ | d
¡ d S )Nr   rh   r‚   rO   rJ   Tr   ZNWé   Ú	clockwise)	r(   r)   r*   r+   r,   rQ   r.   Zset_theta_zero_locationÚset_theta_directionr†   r8   r8   r9   Útest_polar_theta_positionË   s   r•   Zpolar_rlabel_positionc                  C   s.   t  ¡ } | jdd}| d¡ |jdd d S )Nr   r[   i;  Úauto)Úrotation)r+   r,   r-   Zset_rlabel_positionr1   rŒ   r8   r8   r9   Útest_polar_rlabel_position×   s   
r˜   Zpolar_theta_wedgec               	   C   s   t  ddd¡} dt j |  }t  ddd¡}t  ddd¡}d	}tjt|ƒt|ƒd
didd\}}t|ƒD ]Z\}}t|ƒD ]Q\}	}
|||	f }| || ¡ ||
k rZ| |¡ | 	|
¡ n| |
¡ | 	|¡ | 
d¡ |jdd||t|ƒ  dd |jjddd |j ¡ jjg d¢d q;q3d S )Nr   rh   r‚   rO   g      .@g     v@rf   g      I@)r$   ÚinZinoutr   T)é   é   )Ú
subplot_kwZfigsizer“   r–   )r%   r&   r'   r—   )Zlabel2Onr—   )r   rO   g      @é   r;   )Zsteps)r(   r)   r*   r+   ÚsubplotsrY   Ú	enumerater.   Zset_thetaminZset_thetamaxr”   r1   r   Zset_tick_paramsr   Zget_major_locatorÚbaseZ
set_params)r2   r3   Z
theta_minsZ
theta_maxsZ
DIRECTIONSr4   ÚaxsrV   ÚstartÚjÚendr5   r8   r8   r9   Útest_polar_theta_limitsß   s:   
þ



þÿñÿr¥   Zpng)Ú
extensionsc                 C   sP   | j ddid}|jdd |jdd |j ddid}| d¡ | d¡ d S )	Nr   T©rœ   r;   )rP   r=   ©ÚbottomrA   ©rž   Úset_rlimr„   r…   ra   r8   r8   r9   Útest_polar_rlim   s   
r¬   c                 C   sH   | j ddid}|jddgd |j ddid}| d¡ | d¡ d S )Nr   Tr§   r=   r;   r¨   rA   rª   ra   r8   r8   r9   Útest_polar_rlim_bottom  s
   
r­   c                  C   sD   t  ¡ jdd} |  t d¡t d¡d ¡ |  ¡ d dks J ‚d S )Nr   r[   r;   r‚   r   )r+   r,   r-   r.   r(   r)   Úget_ylim©r5   r8   r8   r9   Útest_polar_rlim_zero  s   r°   c                  C   sj   t jdd t  ¡ } |  ¡ dkr|  ¡ dksJ ‚t  d¡ t  ¡  t  ¡ } |  ¡ dkr1|  ¡ dks3J ‚d S )Nr   r[   r   r   Úall)r+   Úsubplotr~   Úget_rminZget_rmaxÚcloser   r¯   r8   r8   r9   Útest_polar_no_data  s   
 rµ   c                  C   s2   t jdd t  ¡ } |  d¡ |  ¡ dksJ ‚d S )Nr   r[   Úlogr   )r+   r²   r~   Ú
set_rscaler³   r¯   r8   r8   r9   Útest_polar_default_log_lims&  s   
r¸   c                  C   sJ   t  ¡ jdd} t t¡ |  d¡ W d   ƒ d S 1 sw   Y  d S )Nr   r[   Zdatalim)r+   r,   r-   ÚpytestÚraisesÚ
ValueErrorZset_adjustabler¯   r8   r8   r9   Ú!test_polar_not_datalim_adjustable-  s   "ÿr¼   c                  C   sv   t  ¡ } | jdd}|jdd t j|j ¡ dd | j ¡  |j	j
d j ¡ dks,J ‚|jj
d j ¡ dks9J ‚d S )NTr   rG   )r>   F)Úvisibler   )r+   r,   r-   ÚgridZsetpr   Zget_ticklabelsÚcanvasÚdrawr   Ú
majorTicksZgridlineZ	get_alpharŒ   r8   r8   r9   Útest_polar_gridlines3  s   
rÂ   c                  C   sF   t jddid\} }| j ¡  | | j ¡ ¡}t|jg d¢dd d S )Nr\   r   r§   )gµ¦yÇñZ@g,ÔšæG=@g_)ËGÞ€@g½R–!Ž+|@r   )Zrtol)r+   rž   r¿   rÀ   Zget_tightbboxZget_rendererr   Zextents)r4   r5   Zbbr8   r8   r9   Útest_get_tightbbox_polar?  s   

ÿrÃ   c                 C   s¤   | j dddjdgdgdtj ddd	}| j d
ddjdgdgdtj ddd	}|j dddjdgdgdtj ddd	}|j d
ddjdgdgdtj ddd	}d S )Néy   r   r[   r   r   r   rŽ   F)Z	edgecolorZantialiasedéz   éýÿÿÿrO   r^   )r-   Úbarr(   r*   )rb   rc   Úp1Úp2Zp3Zp4r8   r8   r9   Ú)test_polar_interpolation_steps_constant_rG  s   ÿÿÿ
ÿrÊ   c                 C   s`   | j dd dtjd gddg¡\}d| ¡ _|j dd t dtjd d¡t ddd¡¡ d S )Nr   r[   r   rO   r   éd   ée   )r-   r.   r(   r*   Úget_pathÚ_interpolation_stepsÚlinspace)rb   rc   Úlr8   r8   r9   Ú)test_polar_interpolation_steps_variable_rU  s
   $
ÿrÑ   c                  C   s®   t jdd} |  ddtj ¡ | jddd tjtdd	 |  dd
tj ¡ W d   ƒ n1 s1w   Y  tjtdd	 | jddd W d   ƒ d S 1 sPw   Y  d S )Nr   r[   r   rO   r   i¸  )ZthetaminZthetamaxz+angle range must be less than a full circle)Úmatchr   i  )r+   r²   Úset_thetalimr(   r*   r¹   rº   r»   r¯   r8   r8   r9   Útest_thetalim_valid_invalid]  s   ÿþÿ"þrÔ   c                  C   sj   t jdd} |  dd¡ tt |  ¡ |  ¡ f¡ƒdksJ ‚|  d¡ tt |  ¡ |  ¡ f¡ƒdks3J ‚d S )Nr   r[   r   r   r   )rO   r   )r+   r²   rÓ   Útupler(   ÚradiansZget_thetaminZget_thetamaxr¯   r8   r8   r9   Útest_thetalim_argsi  s
   "
&r×   c                  C   s|   t jdddid\} }| ¡ D ]	}| dtj¡ q| ¡ D ]}t |j ¡ ¡ 	¡ }t
 d¡|v s2J ‚t
 d¡|vs;J ‚qd S )NzAAAABB.r\   r   r§   r   rF   rË   )r+   Úsubplot_mosaicÚvaluesrÓ   r(   r*   Údegreesr   Zget_majorticklocsÚtolistr¹   Zapprox)r4   r¡   r5   Zticklocsr8   r8   r9   Útest_default_thetalocatorq  s   
ÿýrÜ   c                  C   s4   t jdd} |  dtjd ¡}| ¡ jdksJ ‚d S )Nr   r[   r   rX   r   )r+   r²   Úaxvspanr(   r*   rÍ   rÎ   )r5   Úspanr8   r8   r9   Útest_axvspan  s   rß   c                 C   s`   | j dddddid}dD ]	}|j|  ¡  q|j dddddid}dD ]	}|j|  ¡  q$d S )NrO   Tr\   r   )Úsharexrœ   )r   r   r   )Úshareyrœ   )rž   ZflatÚremove)rc   rb   r¡   rV   r8   r8   r9   Útest_remove_shared_polar…  s   ÿÿÿrã   c                  C   s®   t jddddiddd\} }| j ¡  |d jjd  ¡ sJ ‚|d jjd  ¡ s+J ‚t jdddiddd\} }| j ¡  |d	 jjd  ¡ sIJ ‚|d	 jjd  ¡ sUJ ‚d S )
NrO   r\   r   T)rœ   rà   rá   r   r   zab
cdÚb)	r+   rž   r¿   rÀ   r   rÁ   Zget_visibler   rØ   )r4   r¡   r8   r8   r9   Ú"test_shared_polar_keeps_ticklabels”  s   
ÿ

ÿ
rå   c                  C   sD   t jdd} |  dd¡ |  d¡ |  ddg¡ |  ¡ dks J ‚d S )	Nr   r[   r   r   r=   rK   rG   )r   rG   )r+   r²   rÝ   Zaxvliner.   r®   r¯   r8   r8   r9   Ú(test_axvline_axvspan_do_not_modify_rlims¡  s
   
ræ   c                  C   sÄ   t jdd} |  dd¡dksJ ‚|  dd¡dksJ ‚|  dd¡d	ks$J ‚|  dd¡d
ks.J ‚|  dd¡dks8J ‚|  dd¡dksBJ ‚|  dd¡dksLJ ‚|  dd¡dksVJ ‚|  dd¡dks`J ‚d S )Nr   r[   r   g{®Gázt?u   Î¸=0.0Ï€ (0Â°), r=0.005rK   u   Î¸=0.00Ï€ (0Â°), r=0.100r   u   Î¸=0.000Ï€ (0.0Â°), r=1.000u   Î¸=0.3Ï€ (57Â°), r=0.005u   Î¸=0.32Ï€ (57Â°), r=0.100u   Î¸=0.318Ï€ (57.3Â°), r=1.000rO   u   Î¸=0.6Ï€ (115Â°), r=0.005u   Î¸=0.64Ï€ (115Â°), r=0.100u   Î¸=0.637Ï€ (114.6Â°), r=1.000)r+   r²   Zformat_coordr¯   r8   r8   r9   Útest_cursor_precision©  s   rç   zpolar_log.pngc                  C   sX   t  ¡ } | jdd}| d¡ | dd¡ d}| t ddtj |¡t 	dd|¡¡ d S )	NTr   r¶   r   iè  rË   r   rO   )
r+   r,   r-   r·   r«   r.   r(   rÏ   r*   Zlogspace)r4   r5   Únr8   r8   r9   Útest_polar_log·  s   
*ré   ).Únumpyr(   Znumpy.testingr   r¹   Z
matplotlibrB   r   r+   Zmatplotlib.testing.decoratorsr   r   r:   rE   rW   rZ   rd   rz   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é   r8   r8   r8   r9   Ú<module>   s|    

!ÿ


	










 



	





