o
    ¹iÒ-  ã                   @   s   d dl Z 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e  ¡ dkr0d ndd	d
d„ ƒZedg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d0d1„ ƒZed2gddd3d4„ ƒZed5gd6d7d8„ ƒZed5gd6d9d:„ ƒZd;d<„ Zd=d>„ Z d?d@„ Z!dAdB„ Z"dCdD„ Z#ed5gd6dEdF„ ƒZ$ed5gd6dGdH„ ƒZ%dIdJ„ Z&dS )Ké    N)Úassert_allclose)Úpyplot)Úimage_comparisonÚcheck_figures_equalÚ
polar_axesÚdefaultÚx86_64ç{®Gáz„?)ÚstyleÚtolc               	   C   s¼   t  ddd¡} dt j |  }t ¡ }|jd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?ç      @éo   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?   úV/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/matplotlib/tests/test_polar.pyÚtest_polar_annotations   s$   
ú	rA   Úpolar_coordsT)r
   Úremove_textc                  C   s–   t jjdddddd} t ¡ }|jd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   é
   é   r7   ç      à?)r   Úalphar   Úequal)Úaspectzthe topç       @ç      $@r   g      4@r   r   r   r   r   r    T)r!   r"   Úxycoordsr#   r$   r%   r&   Úclip_oniìÿÿÿ)ÚmplÚpatchesÚEllipser0   r1   r2   Ú
add_artistÚset_clip_boxÚbboxr4   r-   r/   r5   Úset_xlimÚset_ylim)Úelr9   r:   r?   r?   r@   Útest_polar_coord_annotations/   s"   

ørW   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]   r[   r[   TÚ
horizontal)r   ÚlabelÚverticalFé   r   Útop)Úangler%   r&   )r-   r.   r0   r1   Úadd_axesÚset_thetagridsÚpatchÚset_visibleÚrangeÚaxesÚ
set_rgrids)ÚanglesÚgrid_valuesr9   Úrectr^   r`   Úir?   r?   r@   Útest_polar_alignmentK   s   

þÿro   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   ra   r]   rY   r   é   g333333Ó?rZ   z!More than one polar axes created.)r0   r1   r   Úlenri   )r9   r?   r?   r@   Útest_polar_twice`   s   rr   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ÿÿÿrY   r]   ra   éþÿÿÿéµ   if  )r2   r3   r-   Údeg2rad©Úfig_testÚfig_refr:   r?   r?   r@   Útest_polar_wrapg   s   r|   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   rJ   ç      @r   c                    ó   g | ]}|ˆ j  ‘qS r?   ©Údeg©Ú.0r'   ©Úunitsr?   r@   Ú
<listcomp>y   ó    z&test_polar_units_1.<locals>.<listcomp>r   rs   rƒ   )Úxlabel)Úmatplotlib.testing.jpl_unitsÚtestingÚ	jpl_unitsÚregisterr0   r1   Únumberr   r2   r3   r-   rx   Úset)rz   r{   ÚxsÚysr:   r?   r†   r@   Útest_polar_units_1q   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ƒsDJ ‚|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   rs   z{:.12})rŠ   Úylabel)r‹   rŒ   r   rŽ   r0   r1   r   r   Ú
isinstanceÚgcaÚ	get_xaxisÚget_major_formatterÚUnitDblFormatterr2   r3   r-   rx   ÚxaxisÚset_major_formatterrN   ÚtickerÚFuncFormatterÚformatr   )rz   r{   r‘   Úxs_degr’   Úys_kmr:   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€   r	   ra   r\   Tr   rJ   rF   ©	r-   r.   r/   r0   r1   rd   r3   Úset_rmaxÚset_rmin©r7   r8   r9   r:   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	   ra   r\   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	   ra   r\   Tr   rJ   rF   r   )
r-   r.   r/   r0   r1   rd   r3   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 )Nr\   Tr   ra   r   )r0   r1   rd   rU   ©r9   r:   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 )	Nr\   Tr   r   ra   Únone)Úcr   )r0   r1   rd   ÚyaxisÚset_invertedr3   Ú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	   ra   r\   Tr   ÚNWé   Ú	clockwise)	r-   r.   r/   r0   r1   rd   r3   Úset_theta_zero_locationÚset_theta_directionr«   r?   r?   r@   Útest_polar_theta_positionÍ   s   rÁ   Úpolar_rlabel_positionc                  C   s0   t  ¡ } | jddd}| d¡ |jdd d S )Nr   r   rs   i;  Úauto)Úrotation)r0   r1   r2   Úset_rlabel_positionr6   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 ]N\}}t|ƒD ]E\}	}
|||	f }| || ¡ ||
k rZ| |¡ | 	|
¡ n| |
¡ | 	|¡ | 
d¡ |jdd||t|ƒ  dd |jjddd q;q3d S )Nr   r€   r	   ra   g      .@g     v@r~   g      I@)r(   ÚinÚinoutr   T)é   é   )Ú
subplot_kwÚfigsizer¾   rÃ   )r*   r+   r,   rÄ   )Úlabel2OnrÄ   )r-   r.   r/   r0   Úsubplotsrq   Ú	enumerater3   Úset_thetaminÚset_thetamaxrÀ   r6   r·   Úset_tick_params)r7   r8   Ú
theta_minsÚ
theta_maxsÚ
DIRECTIONSr9   Úaxsrn   ÚstartÚjÚendr:   r?   r?   r@   Útest_polar_theta_limitsá   s4   
þ



þòÿ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Ì   rD   )rb   rF   ©ÚbottomrK   ©rÏ   Úset_rlimr©   rª   ry   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Þ   rF   rD   rß   rK   rá   ry   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   rs   rD   r	   r   )r0   r1   r2   r3   r-   r.   Úget_ylim©r:   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   rs   r   r   Úall)r0   Úsubplotr›   Úget_rminÚget_rmaxÚcloser   ræ   r?   r?   r@   Útest_polar_no_data  s   
 rí   c                  C   sJ   t  ¡ jdd} t t¡ |  d¡ W d   ƒ d S 1 sw   Y  d S )Nr   rs   Údatalim)r0   r1   r2   ÚpytestÚraisesÚ
ValueErrorÚset_adjustableræ   r?   r?   r@   Ú!test_polar_not_datalim_adjustable&  s   "ÿró   c                  C   sx   t  ¡ } | jd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s:J ‚d S )	Nr   Tr   rY   )rG   F)Úvisibler   )r0   r1   r2   ÚgridÚsetpr·   Úget_ticklabelsÚcanvasÚdrawrŸ   Ú
majorTicksÚgridlineÚ	get_alphar³   r?   r?   r@   Útest_polar_gridlines,  s   
rý   c                  C   sF   t jddid\} }| j ¡  | | j ¡ ¡}t|jg d¢dd d S )Nrt   r   rÞ   )gµ¦yÇñZ@g,ÔšæG=@g_)ËGÞ€@g½R–!Ž+|@r   )Úrtol)r0   rÏ   rø   rù   Úget_tightbboxÚget_rendererr   Úextents)r9   r:   Úbbr?   r?   r@   Útest_get_tightbbox_polar8  s   

ÿr  c                 C   s¼   | j dddjdgdgdtj dd}| j d	ddjdgdgd
tj dd}|j dddjdgdgdtj dd}|j d	ddjdgdgdtj dd}||||fD ]	}tj|dd qRd S )Néy   r   rs   r   r   r   rµ   )Ú	edgecoloréz   éýÿÿÿra   rv   F)Úantialiased)r2   Úbarr-   r/   r0   rö   )rz   r{   Úp1Úp2Úp3Úp4Úpr?   r?   r@   Ú)test_polar_interpolation_steps_constant_r@  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   rs   r   ra   r   éd   ée   )r2   r3   r-   r/   Úget_pathÚ_interpolation_stepsÚlinspace)rz   r{   Úlr?   r?   r@   Ú)test_polar_interpolation_steps_variable_rP  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   rs   r   ra   r   i¸  )ÚthetaminÚthetamaxzThe angle range must be <= 2 pi)Úmatchr   z&The angle range must be <= 360 degreesi  )r0   ré   Úset_thetalimr-   r/   rï   rð   rñ   ræ   r?   r?   r@   Útest_thetalim_valid_invalidX  s   ÿÿ"þr  )'ÚplatformÚnumpyr-   Únumpy.testingr   rï   Ú
matplotlibrN   r   r0   Úmatplotlib.testing.decoratorsr   r   ÚmachinerA   rW   ro   rr   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@   Ú<module>   sh    ÿ
!


	














	



