o
    l’×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_equalÚ
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é   )ÚcolorÚ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)ÚaxisÚtick1OnÚtick2OnÚ	direction)
ÚnpÚarangeÚpiÚpltÚfigureÚadd_subplotÚplotÚannotateÚdictÚtick_params)ÚrÚthetaÚfigÚaxÚlineÚindÚthisrÚ	thistheta© r=   úY/home/ubuntu/SoloSpeech/.venv/lib/python3.10/site-packages/matplotlib/tests/test_polar.pyÚtest_polar_annotations
   s$   
ú	r?   Úpolar_coordsT)r   Ú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   é
   é   r5   ç      à?)r   ÚalphaÚequal)Úaspectzthe topç       @ç      $@r   g      4@r   r   r   r   r   r   T)r   r    Úxycoordsr!   r"   r#   r$   Úclip_oniìÿÿÿ)ÚmplÚpatchesÚEllipser.   r/   r0   Ú
add_artistÚset_clip_boxÚbboxr2   r+   r-   r3   Úset_xlimÚset_ylim)Úelr7   r8   r=   r=   r>   Útest_polar_coord_annotations,   s"   

ørU   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   ©çš™™™™™¹?r[   rY   rY   TÚ
horizontal)r   ÚlabelÚverticalFé   r   Útop)Úangler#   r$   )r+   r,   r.   r/   Úadd_axesÚset_thetagridsÚpatchÚset_visibleÚrangeÚaxesÚ
set_rgrids)ÚanglesÚgrid_valuesr7   Úrectr\   r^   Úir=   r=   r>   Útest_polar_alignmentI   s   

þÿrm   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   r_   r[   rW   r   é   g333333Ó?rX   z!More than one polar axes created.)r.   r/   r   Úlenrg   )r7   r=   r=   r>   Útest_polar_twice^   s   rp   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ÿÿÿrW   r[   r_   éþÿÿÿéµ   if  )r0   r1   r+   Údeg2rad©Úfig_testÚfig_refr8   r=   r=   r>   Útest_polar_wrape   s   rz   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   rH   ç      @r   c                    ó   g | ]}|ˆ j  ‘qS r=   ©Údeg©Ú.0r%   ©Úunitsr=   r>   Ú
<listcomp>w   ó    z&test_polar_units_1.<locals>.<listcomp>r   rq   r   )Úxlabel)Úmatplotlib.testing.jpl_unitsÚtestingÚ	jpl_unitsÚregisterr.   r/   Únumberr   r0   r1   r+   rv   Úset)rx   ry   ÚxsÚysr8   r=   r„   r>   Útest_polar_units_1o   s   r‘   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   r{   c                    r   r=   r€   r‚   r„   r=   r>   r†   ƒ   r‡   z&test_polar_units_2.<locals>.<listcomp>r}   c                    r   r=   )Úkm)rƒ   Úyr„   r=   r>   r†   …   r‡   Úradr’   )Ú
thetaunitsÚrunitsr   rq   z{:.12})rˆ   Úylabel)r‰   rŠ   r‹   rŒ   r.   r/   r   r   Ú
isinstanceÚgcaÚxaxisÚget_major_formatterÚUnitDblFormatterr0   r1   r+   rv   Úset_major_formatterrL   ÚtickerÚFuncFormatterÚformatrŽ   )rx   ry   r   Úxs_degr   Úys_kmr8   r=   r„   r>   Útest_polar_units_2~   s   ÿr£   Ú
polar_rmin)r   c                  C   sZ   t  ddd¡} dt j |  }t ¡ }|jg d¢dd}| || ¡ | d¡ | d	¡ d S )
Nr   r~   ç{®Gáz„?r_   rZ   Tr   rH   rD   ©	r+   r,   r-   r.   r/   rb   r1   Úset_rmaxÚset_rmin©r5   r6   r7   r8   r=   r=   r>   Útest_polar_rmin“   ó   
rª   Ú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¥   r_   rZ   Tr   r¦   r©   r=   r=   r>   Útest_polar_negative_rminŸ   r«   r­   Úpolar_roriginc                  C   sd   t  ddd¡} dt j |  }t ¡ }|jg d¢dd}| || ¡ | d¡ | d	¡ | 	d
¡ d S )Nr   r~   r¥   r_   rZ   Tr   rH   rD   r
   )
r+   r,   r-   r.   r/   rb   r1   r§   r¨   Úset_roriginr©   r=   r=   r>   Útest_polar_rorigin«   s   

r°   zpolar_invertedylim.pngc                  C   s*   t  ¡ } | jg d¢dd}| dd¡ d S )NrZ   Tr   r_   r   )r.   r/   rb   rS   ©r7   r8   r=   r=   r>   Ú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 )	NrZ   Tr   r   r_   Únone)Úcr   )r.   r/   rb   ÚyaxisÚset_invertedr1   Úmarginsr¯   r±   r=   r=   r>   Útest_polar_invertedylim_rorigin¿   s   
r¸   Úpolar_theta_positionc                  C   s\   t  ddd¡} dt j |  }t ¡ }|jg d¢dd}| || ¡ | dd	¡ | d
¡ d S )Nr   r~   r¥   r_   rZ   Tr   ÚNWé   Ú	clockwise)	r+   r,   r-   r.   r/   rb   r1   Úset_theta_zero_locationÚset_theta_directionr©   r=   r=   r>   Útest_polar_theta_positionË   s   r¿   Úpolar_rlabel_positionc                  C   s.   t  ¡ } | jdd}| d¡ |jdd d S )Nr   rq   i;  Úauto)Úrotation)r.   r/   r0   Úset_rlabel_positionr4   r±   r=   r=   r>   Útest_polar_rlabel_position×   s   
rÄ   Ú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   r~   r¥   r_   g      .@g     v@r|   g      I@)r&   ÚinÚinoutr   T)é   é   )Ú
subplot_kwÚfigsizer¼   rÁ   )r(   r)   r*   rÂ   )Úlabel2OnrÂ   )r   r_   g      @é   rB   )Ústeps)r+   r,   r-   r.   Úsubplotsro   Ú	enumerater1   Úset_thetaminÚset_thetamaxr¾   r4   rµ   Úset_tick_paramsrš   Úget_major_locatorÚbaseÚ
set_params)r5   r6   Ú
theta_minsÚ
theta_maxsÚ
DIRECTIONSr7   Úaxsrl   ÚstartÚjÚendr8   r=   r=   r>   Útest_polar_theta_limitsß   s:   
þ



þÿñÿrÞ   Ú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Ê   rB   )r`   rD   ©ÚbottomrI   ©rÏ   Úset_rlimr§   r¨   rw   r=   r=   r>   Ú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á   rD   rB   râ   rI   rä   rw   r=   r=   r>   Ú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   rq   rB   r¥   r   )r.   r/   r0   r1   r+   r,   Úget_ylim©r8   r=   r=   r>   Ú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   rq   r   r   Úall)r.   Úsubplotr™   Úget_rminÚget_rmaxÚcloser   ré   r=   r=   r>   Útest_polar_no_data  s   
 rð   c                  C   s2   t jdd t  ¡ } |  d¡ |  ¡ dksJ ‚d S )Nr   rq   Úlogr   )r.   rì   r™   Ú
set_rscalerí   ré   r=   r=   r>   Ú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   rq   Údatalim)r.   r/   r0   ÚpytestÚraisesÚ
ValueErrorÚset_adjustableré   r=   r=   r>   Ú!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   rW   )rE   F)Úvisibler   )r.   r/   r0   ÚgridÚsetprµ   Úget_ticklabelsÚcanvasÚdrawrš   Ú
majorTicksÚgridlineÚ	get_alphar±   r=   r=   r>   Útest_polar_gridlines3  s   
r  c                  C   sF   t jddid\} }| j ¡  | | j ¡ ¡}t|jg d¢dd d S )Nrr   r   rá   )gµ¦yÇñZ@g,ÔšæG=@g_)ËGÞ€@g½R–!Ž+|@r   )Úrtol)r.   rÏ   rþ   rÿ   Úget_tightbboxÚget_rendererr   Úextents)r7   r8   Úbbr=   r=   r>   Ú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   rq   r   r   r   r³   F)Ú	edgecolorÚantialiasedéz   éýÿÿÿr_   rt   )r0   Úbarr+   r-   )rx   ry   Úp1Úp2Úp3Úp4r=   r=   r>   Ú)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   rq   r   r_   r   éd   ée   )r0   r1   r+   r-   Úget_pathÚ_interpolation_stepsÚlinspace)rx   ry   Úlr=   r=   r>   Ú)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   rq   r   r_   r   i¸  )ÚthetaminÚthetamaxz+angle range must be less than a full circle)Úmatchr   i  )r.   rì   Úset_thetalimr+   r-   rõ   rö   r÷   ré   r=   r=   r>   Ú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   rq   r   r   r   )r_   r   )r.   rì   r  Útupler+   ÚradiansÚget_thetaminÚget_thetamaxré   r=   r=   r>   Ú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.rr   r   rá   r   rV   r  )r.   Úsubplot_mosaicÚvaluesr  r+   r-   Údegreesrš   Úget_majorticklocsÚtolistrõ   Úapprox)r7   rÚ   r8   Úticklocsr=   r=   r>   Útest_default_thetalocatorq  s   
ÿýr-  c                  C   s4   t jdd} |  dtjd ¡}| ¡ jdksJ ‚d S )Nr   rq   r   rn   r   )r.   rì   Úaxvspanr+   r-   r  r  )r8   Úspanr=   r=   r>   Útest_axvspan  s   r0  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 )Nr_   Trr   r   )ÚsharexrÊ   )r   r   r   )ÚshareyrÊ   )rÏ   ÚflatÚremove)ry   rx   rÚ   rl   r=   r=   r>   Útest_remove_shared_polar…  s   ÿÿÿr5  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 )
Nr_   rr   r   T)rÊ   r1  r2  r   r   zab
cdÚb)	r.   rÏ   rþ   rÿ   rš   r   Úget_visiblerµ   r&  )r7   rÚ   r=   r=   r>   Ú"test_shared_polar_keeps_ticklabels”  s   
ÿ

ÿ
r8  c                  C   sD   t jdd} |  dd¡ |  d¡ |  ddg¡ |  ¡ dks J ‚d S )	Nr   rq   r   r   rD   r[   rW   )r   rW   )r.   rì   r.  Úaxvliner1   rè   ré   r=   r=   r>   Ú(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   rq   r   g{®Gázt?u   Î¸=0.0Ï€ (0Â°), r=0.005r[   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.000r_   u   Î¸=0.6Ï€ (115Â°), r=0.005u   Î¸=0.64Ï€ (115Â°), r=0.100u   Î¸=0.637Ï€ (114.6Â°), r=1.000)r.   rì   Úformat_coordré   r=   r=   r>   Ú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   r_   )
r.   r/   r0   rò   rå   r1   r+   r  r-   Úlogspace)r7   r8   Únr=   r=   r>   Útest_polar_log·  s   
*r?  ).Únumpyr+   Únumpy.testingr   rõ   Ú
matplotlibrL   r   r.   Úmatplotlib.testing.decoratorsr   r   r?   rU   rm   rp   rz   r‘   r£   rª   r­   r°   r²   r¸   r¿   rÄ   rÞ   ræ   rç   rê   rð   ró   rù   r  r	  r  r  r   r%  r-  r0  r5  r8  r:  r<  r?  r=   r=   r=   r>   Ú<module>   s|    

!ÿ


	










 



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