o
    ¡:´a:  ã                   @   s.  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!ed4gd5dDdE„ ƒZ"ed4gd5dFdG„ ƒZ#dHdI„ Z$dJdK„ Z%dLdM„ Z&dNdO„ Z'ed4gd5dPdQ„ ƒZ(dRdS„ Z)dTdU„ Z*dVdW„ Z+dS )Xé    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é   )ZcolorZlw©r   r   ©r   é   z#0000ffr   é   Úoza polar annotation)çš™™™™™©?r   zfigure fractionÚblackr   ©Ú	facecolorZ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ÚlineZindZthisrZ	thistheta© r5   ú=/usr/lib/python3/dist-packages/matplotlib/tests/test_polar.pyÚtest_polar_annotations
   s$   
ú	r7   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   é
   é   r0   ç      à?)r   ÚalphaZ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(   r.   Zset_xlimÚset_ylim)Úelr2   r3   r5   r5   r6   Útest_polar_coord_annotations,   s"   

ørA   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   ©çš™™™™™¹?rG   rE   rE   TÚ
horizontal)r   ZlabelÚverticalFé   r   Útop)Zangler   r    )r&   r'   r)   r*   Úadd_axesZset_thetagridsZpatchZset_visibleÚrangeÚaxesZ
set_rgrids)ZanglesZgrid_valuesr2   ZrectrH   rI   Úir5   r5   r6   Útest_polar_alignmentI   s   

þÿrP   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   rJ   rG   rC   r   é   g333333Ó?rD   z!More than one polar axes created.)r)   r*   r   ÚlenrN   )r2   r5   r5   r6   Útest_polar_twice^   s   rS   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ÿÿÿrC   rG   rJ   éþÿÿÿéµ   if  )r+   r,   r&   Údeg2rad©Úfig_testÚfig_refr3   r5   r5   r6   Útest_polar_wrape   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
   r<   ç      @r   c                    ó   g | ]}|ˆ j  ‘qS r5   ©Údeg©Ú.0r!   ©Zunitsr5   r6   Ú
<listcomp>w   ó    z&test_polar_units_1.<locals>.<listcomp>r   rT   rd   )Úxlabel)Úmatplotlib.testing.jpl_unitsÚtestingÚ	jpl_unitsÚregisterr)   r*   Únumberr   r+   r,   r&   rY   Úset)r[   r\   ÚxsÚysr3   r5   rg   r6   Útest_polar_units_1o   s   rs   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                    rb   r5   rc   re   rg   r5   r6   rh   ƒ   ri   z&test_polar_units_2.<locals>.<listcomp>r`   c                    rb   r5   )Úkm)rf   Úyrg   r5   r6   rh   …   ri   Zradrt   )Z
thetaunitsZrunitsr   rT   z{:.12})rj   Zylabel)rk   rl   rm   rn   r)   r*   ro   r   Ú
isinstanceÚgcaÚxaxisZget_major_formatterZUnitDblFormatterr+   r,   r&   rY   Zset_major_formatterr>   ZtickerZFuncFormatterÚformatrp   )r[   r\   rq   Zxs_degrr   Zys_kmr3   r5   rg   r6   Útest_polar_units_2~   s   ÿrz   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   ra   ç{®Gáz„?rJ   rF   Tr   r<   r:   ©	r&   r'   r(   r)   r*   rL   r,   Úset_rmaxÚset_rmin©r0   r1   r2   r3   r5   r5   r6   Ú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{   rJ   rF   Tr   r|   r   r5   r5   r6   Ú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   ra   r{   rJ   rF   Tr   r<   r:   r	   )
r&   r'   r(   r)   r*   rL   r,   r}   r~   Úset_roriginr   r5   r5   r6   Útest_polar_rorigin«   s   

r„   zpolar_invertedylim.pngc                  C   s*   t  ¡ } | jg d¢dd}| dd¡ d S )NrF   Tr   rJ   r   )r)   r*   rL   r?   ©r2   r3   r5   r5   r6   Ú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 )	NrF   Tr   r   rJ   Únone)Úcr   )r)   r*   rL   ÚyaxisZset_invertedr,   Zmarginsrƒ   r…   r5   r5   r6   Ú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   ra   r{   rJ   rF   Tr   ZNWé   Ú	clockwise)	r&   r'   r(   r)   r*   rL   r,   Zset_theta_zero_locationÚset_theta_directionr   r5   r5   r6   Útest_polar_theta_positionË   s   rŽ   Zpolar_rlabel_positionc                  C   s.   t  ¡ } | jdd}| d¡ |jdd d S )Nr   rT   i;  Úauto)Úrotation)r)   r*   r+   Zset_rlabel_positionr/   r…   r5   r5   r6   Ú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   ra   r{   rJ   g      .@g     v@r_   g      I@)r"   ÚinZinoutr   T)é   é   )Ú
subplot_kwZfigsizerŒ   r   )r#   r$   r%   r   )Zlabel2Onr   )r   rJ   g      @é   r8   )Zsteps)r&   r'   r(   r)   ÚsubplotsrR   Ú	enumerater,   Zset_thetaminZset_thetamaxr   r/   r‰   Zset_tick_paramsrx   Zget_major_locatorÚbaseZ
set_params)r0   r1   Z
theta_minsZ
theta_maxsZ
DIRECTIONSr2   ÚaxsrO   ÚstartÚjÚendr3   r5   r5   r6   Ú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•   r8   )rK   r:   ©Zbottomr=   ©r—   Zset_rlimr}   r~   rZ   r5   r5   r6   Ú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:   r8   r¡   r=   r¢   rZ   r5   r5   r6   Ú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   rT   r8   r{   r   )r)   r*   r+   r,   r&   r'   Úget_ylim©r3   r5   r5   r6   Ú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   rT   r   r   Úall)r)   Úsubplotrw   Zget_rminZget_rmaxÚcloser   r¦   r5   r5   r6   Ú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   rT   Zdatalim)r)   r*   r+   ÚpytestÚraisesÚ
ValueErrorZset_adjustabler¦   r5   r5   r6   Ú!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   rC   )r;   F)Zvisibler   )r)   r*   r+   ZgridZsetpr‰   Zget_ticklabelsÚcanvasÚdrawrx   Ú
majorTicksZgridlineZ	get_alphar…   r5   r5   r6   Útest_polar_gridlines,  s   
r³   c                  C   sF   t jddid\} }| j ¡  | | j ¡ ¡}t|jg d¢dd d S )NrU   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)r2   r3   Zbbr5   r5   r6   Útest_get_tightbbox_polar8  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   rT   r   r   r   r‡   F)Z	edgecolorZantialiasedéz   éýÿÿÿrJ   rW   )r+   Zbarr&   r(   )r[   r\   Zp1Zp2Zp3Zp4r5   r5   r6   Ú)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   rT   r   rJ   r   éd   ée   )r+   r,   r&   r(   Úget_pathÚ_interpolation_stepsZlinspace)r[   r\   Úlr5   r5   r6   Ú)test_polar_interpolation_steps_variable_rN  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   rT   r   rJ   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¦   r5   r5   r6   Útest_thetalim_valid_invalidV  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   rT   r   r   r   )rJ   r   )r)   r©   rÀ   Útupler&   ZradiansZget_thetaminZget_thetamaxr¦   r5   r5   r6   Útest_thetalim_argsb  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.rU   r   r    r   rB   r¹   )r)   Úsubplot_mosaicÚvaluesrÀ   r&   r(   Zdegreesrx   Zget_majorticklocsÚtolistr¬   Zapprox)r2   rš   r3   Zticklocsr5   r5   r6   Útest_default_thetalocatorj  s   
ÿýrÇ   c                  C   s4   t jdd} t  dtjd ¡}| ¡ jdksJ ‚d S )Nr   rT   r   rQ   r   )r)   r©   Úaxvspanr&   r(   r»   r¼   )r3   Úspanr5   r5   r6   Útest_axvspanx  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 )NrJ   TrU   r   )Úsharexr•   )r   r   r   )Úshareyr•   )r—   ZflatÚremove)r\   r[   rš   rO   r5   r5   r6   Ú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 )
NrJ   rU   r   T)r•   rË   rÌ   r   r   zab
cdÚb)	r)   r—   r°   r±   rx   r²   Zget_visibler‰   rÄ   )r2   rš   r5   r5   r6   Ú"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   rT   r   r   r:   rG   rC   )r   rC   )r)   r©   rÈ   Zaxvliner,   r¥   r¦   r5   r5   r6   Ú(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   rT   r   u   Î¸=0Ï€ (0Â°), r=0.000rG   u   Î¸=0.00Ï€ (0Â°), r=0.100r   u   Î¸=0.000Ï€ (0.0Â°), r=1.000u   Î¸=0.3Ï€ (57Â°), r=0.000u   Î¸=0.32Ï€ (57Â°), r=0.100u   Î¸=0.318Ï€ (57.3Â°), r=1.000rJ   u   Î¸=0.6Ï€ (115Â°), r=0.000u   Î¸=0.64Ï€ (115Â°), r=0.100u   Î¸=0.637Ï€ (114.6Â°), r=1.000)r)   r©   Zformat_coordr¦   r5   r5   r6   Útest_cursor_precision¢  s   rÒ   ),Znumpyr&   Znumpy.testingr   r¬   Z
matplotlibr>   r   r)   Zmatplotlib.testing.decoratorsr   r   r7   rA   rP   rS   r]   rs   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Ò   r5   r5   r5   r6   Ú<module>   sv    

!ÿ


	










 



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