U
    e»{j„  ã                
   @   s0  d Z ddlZddlZddlmZ ddlmZ ddlmZ	 ddl
mZ ddlmZ ddlmZ d	d
„ Zej de	je	je	jf¡dd„ ƒZe	je	je	jgZej de¡dd„ ƒZej de¡dd„ ƒZej de¡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Z!ej de"e#ee!ƒƒ¡dd„ ƒZ$dde	j% dfZ&ej de"e#ee&ƒƒ¡d d!„ ƒZ'ej d"dde	j(e	j)  fd#d$e	j*e	j)  fd%d&e	j*e	j)  fg¡d'd(„ ƒZ+d)d*„ Z,d+d,„ Z-d-d.„ Z.d/d0„ Z/d1d2„ Z0d3d4„ Z1d5d6„ Z2d7d8„ Z3ej d9d:d;d<ge	j4fd=d>d?ge	j5d% fd@dAdBge	j6fdCdDdEge	j7fg¡dFdG„ ƒZ8ej dHdIe	j4 dJe	j6 dKdIe	j4  dLe	j7 f¡dMdN„ ƒZ9dOdP„ Z:dQdR„ Z;dSdT„ Z<dUdV„ Z=ej dWe	j>e	j?dX  e	j) e	j?e	j? e	j) d% fe	j>e	j?dX  e	j) e	j@e	j?e	j? e	j) e	jA  fe	j@e	j?dX  e	j) e	j?e	j? e	j) d% fe	j@e	j?dX  e	j) e	j@e	j?e	j? e	j) e	jA  fg¡dYdZ„ ƒZBd[d\„ ZCd]d^„ ZDd_d`„ ZEdadb„ ZFdcdd„ ZGdedf„ ZHdgdh„ ZIdidj„ ZJdkdl„ ZKdmdn„ ZLdodp„ ZMdqdr„ ZNdsdt„ ZOdudv„ ZPdwdx„ ZQdydz„ ZRd{d|„ ZSd}d~„ ZTdd€„ ZUd�d‚„ ZVdƒd„„ ZWd…d†„ ZXd‡dˆ„ ZYdS )‰z.Separate tests specifically for equivalencies.é    N)Úassert_allclose)Ú	constants)Úunits)Úassert_quantity_allclose)ÚEquivalency)ÚAstropyDeprecationWarningc                     sx  t  ¡ ‰ t jjdˆ d�dks t‚t jjdˆ d�t j t j¡ksBt‚t jjdˆ d�dksZt‚t jjt jˆ d�dkstt‚dt j j	dˆ d�dks�t‚dt j j	dˆ d�t j t j¡ks¶t‚dt j j	dˆ d�dksÒt‚dt j
 t jd  } t jdt j  }d|  |d  }|jt jˆ d�}t|j|t jd   	t j¡ƒ G ‡ fdd„dt jƒ}|dt jƒ}| 	d¡t j t j¡k�stt‚d S )	Né   ©Úequivalenciesç      ð?gž\Cð·kFIé   ç      à?c                       s   e Zd Z” ZdS )z)test_dimensionless_angles.<locals>.MyRad1N)Ú__name__Ú
__module__Ú__qualname__Z_equivalencies© ©Zrad1r   úe/var/www/html/bwave/python/venv/lib/python3.8/site-packages/astropy/units/tests/test_equivalencies.pyÚMyRad1(   s   r   )ÚuÚdimensionless_anglesÚradianÚtoÚAssertionErrorÚdegZradZ	steradianÚdimensionless_unscaledÚto_valueÚgÚcmÚcycleÚsÚergr   ÚvalueÚQuantity)ÚIÚOmegaZErotZErot_in_erg1r   Úphaser   r   r   Útest_dimensionless_angles   s     "&r'   Úlog_unitc              	   C   s8  t  tj¡� |  dd¡ W 5 Q R X t  tj¡� tj | ¡ W 5 Q R X | jddt ¡ d�dksdt‚tjj| t ¡ d�dks€t‚t 	ddddg¡tj
 }d|j tj }| | ¡}t |jdt ¡ d�|k¡sÒt‚t |j| t ¡ d�|k¡sòt‚t t ¡ ¡�. t t || | ¡ ¡d|  k ¡�s*t‚W 5 Q R X d S )	Nr   g        r	   r   g      ð¿ç       @ç      $@g»½×Ùß|Û=)ÚpytestÚraisesr   Ú
UnitsErrorr   r   Zlogarithmicr   ÚnpÚarrayÚdexr"   ÚallÚset_enabled_equivalenciesÚabs)r(   Zq_dexZ
q_expectedZ
q_log_unitr   r   r   Útest_logarithmic/   s    
  r4   Úfunctionc                 C   s6   dt j }|jt jt j | |ƒd�}|jdks2t‚d S )Nçq=
×£@Z@r	   r   )r   ÚGHzr   Úkmr    r"   r   )r5   ÚrestÚvelo0r   r   r   Útest_doppler_frequency_0G   s    
r;   c                 C   sF   dt j }dt j }|jt jt j | |ƒd�}tjj|j	ddd� d S )Nr6   g]ZÁ¾%cg?r	   r   é   ©Údecimal)
r   r7   Úmr   r8   r    r.   ÚtestingÚassert_almost_equalr"   ©r5   r9   Úq1r:   r   r   r   Útest_doppler_wavelength_0N   s    

rD   c                 C   sF   dt j }dt j }|jt jt j | |ƒd�}tjj|j	ddd� d S )Nr6   gŒ†ä)v<?r	   r   r<   r=   )
r   r7   ÚeVr   r8   r    r.   r@   rA   r"   rB   r   r   r   Útest_doppler_energy_0V   s    

rF   c                 C   s\   dt j }dt j }|jt jt j | |ƒd�}|jt j| |ƒd�}tjj|j|jdd� d S ©Nr6   gR¸…ëAZ@r	   é   r=   )	r   r7   r   r8   r    r.   r@   rA   r"   )r5   r9   ÚshiftedÚveloÚfreqr   r   r   Útest_doppler_frequency_circle^   s
    

rL   c                 C   s\   dt j }dt j }|jt jt j | |ƒd�}|jt j| |ƒd�}tjj|j|jdd� d S rG   )	r   Únmr   r8   r    r.   r@   rA   r"   )r5   r9   rI   rJ   Úwavr   r   r   Útest_doppler_wavelength_circleg   s
    

rO   c                 C   s\   dt j }dt j }|jt jt j | |ƒd�}|jt j| |ƒd�}tjj|j|jdd� d S )Ng>yX¨5Íð?g Òo_Îð?r	   rH   r=   )	r   rE   r   r8   r    r.   r@   rA   r"   )r5   r9   rI   rJ   Úenr   r   r   Útest_doppler_energy_circlep   s
    

rQ   )gÝf'3?�@g€ç3?�@gos‡3?�@©r5   r"   c                 C   sF   dt j }dt j t j }|jt j| |ƒd�}tjj|j|dd� d S )Néè  é   r	   rH   r=   )	r   r7   r8   r    r   r.   r@   rA   r"   )r5   r"   r9   rJ   rI   r   r   r   Ú
test_30kms|   s    
rU   é   c              	   C   s$   t  tj¡� | |ƒ W 5 Q R X d S ©N)r+   r,   r   r-   rR   r   r   r   Útest_bad_restfreqs‰   s    rX   )ÚzÚrv_ansgü©ñÒMbP?geƒT?êIAéÿÿÿÿg   JxÞ±Ác                 C   sL   | t j }| t jt j t  ¡ ¡}| t jt  ¡ ¡}t||ƒ t||ƒ d S rW   )r   r   r   r8   r    Údoppler_redshiftr   )rY   rZ   Zz_inZrv_outZz_outr   r   r   Útest_doppler_redshift‘   s
    	

r]   c               	   C   sH   ddl m}  tjtjdd��" dtjtj   | t 	¡ ¡ W 5 Q R X d S )Nr   ©Úredshiftúnot convertible©Úmatch)
Zastropy.cosmology.unitsr_   r+   r,   r   ÚUnitConversionErrorr8   r    r   r\   r^   r   r   r   Ú"test_doppler_redshift_no_cosmology¡   s    rd   c                  C   s*  t  dddddgt j¡} t  dddd	d
gt j¡}tj| jt jt  ¡ d�|jdd�sVt	‚tj|jt jt  ¡ d�| jdd�s|t	‚t  dt jt j
d  ¡}t  dt jt jd  ¡}tj|jt jt jd  t  ¡ d�|jdd�sÜt	‚tj|jt jt j
d  t  ¡ d�|jdd��st	‚t  dt jt j
d  ¡}t  dt jt jd  ¡}tj|jt jt jd  t  ¡ d�|jdd��spt	‚tj|jt jt j
d  t  ¡ d�|jdd��s¢t	‚t  dt jt j ¡}t  d
t jt j ¡}tj|jt jt j t  ¡ d�|jdd��søt	‚tj|jt jt j t  ¡ d�|jdd��s&t	‚d S )NgË¡E¶[0Ag   —röËAg   ¡P ÌAg   à0™AgtãºéK¨»FgAµ�R:gQßñÿ5- ;gŒø¶Të2 ;g»K»Öo%Í:r   r	   gH¯¼šò×z>©Zrtolr   g-Cëâ6?é   ç�íµ ÷Æ°>)r   r#   rE   r   r.   Zallcloser   Zmass_energyr"   r   r?   r   r    )Zmass_eVZmass_gZsdens_eVZsdens_gZdens_eVZdens_gZpow_eVZpow_gr   r   r   Útest_massenergy¨   sl    þ ÿ  ÿ
  ÿ
ý
ýýýýýrh   c                   C   s\  t j t j¡st‚t j t j¡s$t‚t j t j¡r6t‚t j t jt  ¡ ¡sNt‚t j	 t j
¡r`t‚t j	 t j
t  ¡ ¡sxt‚t j
 t j	t  ¡ ¡s�t‚t j t jt  ¡ ¡s¨t‚t j t jt  ¡ ¡sÀt‚t j t jt jt jf¡sÜt‚t j t jt jt jf¡søt‚t j t jt jt jf¡�st‚t j t jt jt jf¡�r4t‚t jt j  t jt jt jf¡�rXt‚d S rW   )r   r?   Úis_equivalentÚpcr   r   Úmasr   r   ÚHzÚJÚspectralÚ	arcsecondÚparallaxÚ	arcminuteÚaur   r    ÚkgÚmsr   ÚLr8   r   r   r   r   Útest_is_equivalentî   s    rv   c                  C   sâ   t j t jdt  ¡ ¡} t| ddd� t j t j| t  ¡ ¡}t|ddd� t j t jdt  ¡ ¡} t| ddd� t j t j| t  ¡ ¡}t|ddd� dt j  t jt  ¡ ¡}t	 
|j¡s¸t‚dt j  t jt  ¡ ¡}t	 
|¡sÞt‚d S )Né
   çš™™™™™¹?çê-�™—q=re   r   g^†½X~Ûª@r[   )r   ro   r   rj   rp   r   rq   rr   rk   r.   Úisnanr"   r   r   )ÚaÚbÚvalr   r   r   Útest_parallax  s    r~   c                  C   s0   t j t jddgt  ¡ ¡} t| ddgdd� d S )Nrx   ç      @rw   çš™™™™™Ù?ry   re   )r   ro   r   rj   rp   r   ©r{   r   r   r   Útest_parallax2  s    r‚   c                  C   sÄ   t j t jdt  ¡ ¡} t| dƒ t j t j| t  ¡ ¡}t|dƒ t j t jdt  ¡ ¡} t| dƒ t j t j| t  ¡ ¡}t|dƒ t j t jdt  ¡ ¡} t| dƒ t j t j| t  ¡ ¡}t|dƒ d S )Nr   gó'ËBbÍÄCgÿÿTÖÐ…BgÿÿÿIxÞ±A)r   ÚAAr   rl   rn   r   ZMHzr?   )r{   r|   r   r   r   Útest_spectral  s    




r„   c                  C   s°   t j t jdt  ¡ ¡} t| dƒ t j t j| t  ¡ ¡}t|dƒ t j t jdt  ¡ ¡} t j t j| t  ¡ ¡}t j t jdt  ¡ ¡}t||ƒ t j t j|t  ¡ ¡}t| |ƒ d S )Niô  g÷Úoa”P<r   )r   rM   r   rm   rn   r   rƒ   rl   )r{   r|   Úcr   r   r   Útest_spectral2)  s    


r†   c                  C   s,   t j t jddgt  ¡ ¡} t| ddgƒ d S )NrS   iÐ  ç hrï�
ñBg hrï�
áB)r   rM   r   rl   rn   r   r�   r   r   r   Útest_spectral38  s    rˆ   )Úin_valÚin_unitrx   g     ˆ³@g     ˆÃ@ç     jø@r)   r   gññ}Óº úCg hrï�
Cr‡   g½Žø3Š]=g#�Ýa”P<g€£ `”P<c                 C   sz   t jd t jt j g}dddgdddgg}t||ƒD ]@\}}| || t  ¡ ¡}t||ƒ | ||t  ¡ ¡}t|| ƒ q4dS )	z;Wave number conversion w.r.t. wavelength, freq, and energy.r[   r‹   r)   r   gd;ß½,#AgñÔÈSû!)@gh¡tTû!@N)r   Úmicronr   Úzipr   rn   r   )r‰   rŠ   Z	out_unitsZanswersZout_unitZansr{   r|   r   r   r   Útest_spectral4=  s    
rŽ   rN   i¬  g p£z8XCr   g«.jð$<c                 C   s"  t jt j t jd  t j }t jt j t jd  t j }| |dt  | ¡¡}t|dƒ t jt jd  t j }t j	t jd  t j }| |dt  | ¡¡}t|dƒ | |dt  | ¡¡}t|dƒ t jt j t j }t jt j t j }| |dt  | ¡¡}t|dƒ | |dt  | ¡¡}t|dƒ d S )Nr   r   gv’Q{›ø‘=g  €&þ‚DBg­aí¬ö˜=g²m�z}LB)
r   r!   Úangstromr   r    rl   r   Úspectral_densityr   Úph)rN   ZflambdaÚfnur{   Zf_intZphot_intZllambdaZlnur   r   r   Útest_spectraldensity2V  s     



r“   c               
   C   s  t j} t jt jd  t j t j }t  dt j¡}t|  	t jt jd  t j t j
 d¡ddƒ t| j	t jt jd  t j dt  |d ¡d�dƒ t| j	|dt  |¡d�dƒ t|j	t jdt  |¡d�d	ƒ t|j	t jt jd  t j dt  t  dt j¡¡d�d
ƒ d S )Nr   r   r   gQ²@³-(;rw   r	   g‚vIhÂ%<=g7�J—­°ã;gðñ}Óº úCr*   )r   ÚJyr!   r   r    rŒ   r#   r7   r   r   rl   r�   )Zf_nuZf_lambdaZone_ghzr   r   r   Útest_spectraldensity3v  s8    ,  ÿüþþýúr•   c                  C   sº  t jt jd t j t j  } t jt jd t j t j  }t jt jd t j t j  }t jt jd t j t j  }t  dddgt j¡}dddg}dd	d
g}dddg}dddg}dddg}	dddg}
dddg}t| 	| |t  
|¡¡|dd� t|  	||t  
|¡¡|dd� t| 	||t  
|¡¡|dd� t| 	||t  
|¡¡|dd� t| 	t j|t  
|¡¡|	dd� tt j 	||	t  
|¡¡|dd� t| 	||t  
|¡¡|dd� t| 	||t  
|¡¡|dd� t| 	||t  
|¡¡|dd� t| 	||t  
|¡¡|dd� t| 	| |t  
|¡¡|dd� t|  	||t  
|¡¡|dd� t| 	t j|t  
|¡¡|
dd� tt j 	||
t  
|¡¡|dd� t| 	t j|t  
|¡¡|dd� tt j 	||t  
|¡¡|dd� dS )zPHOTLAM and PHOTNU conversions.r   çÍÌÌÌÌ\³@çÍÌÌÌŒ_³@çÍÌÌÌLb³@çìÍáÿƒ?ç¨9gN�„?çu0Í:
„?ç³Û”‡6=ç2Æ)/7=çÏ ŸdEŸ6=ç®<�¨ò&=çîÄÑCº¢&=çˆøˆ	Ù&=çs)N­ÓÐØ:çÙ­/8j†Ù:çìZ7ØväØ:gÃ–u»òk ?gŠòä ?gËÒÇnñx ?g›•HýPÖ(@gœŠu&DÇ(@gàÚ&hÕÕ(@g9º)iîD)@gx\·µC5)@gÌ�š17C)@rg   re   N)r   r!   r   r    rƒ   rl   Úphotonr#   r   r   r�   r”   ZSTmagZABmag)Zflamr’   ZphotlamZphotnuÚwaveZflux_photlamZflux_photnuZ	flux_flamZflux_fnuZflux_jyZ
flux_stmagZ
flux_abmagr   r   r   Útest_spectraldensity4¢  s¸    






  ÿ  ÿ  ÿ  ÿ  ÿ  ÿýý  ÿ  ÿ  ÿ  ÿýýýýr§   c            	      C   s´  t jt jt j  } t jt jt j  }t jt jt j  }t jt jt j  }t  dddgt j¡}dddg}ddd	g}d
ddg}dddg}t| | |t  	|¡¡|dd� t|  ||t  	|¡¡|dd� t| ||t  	|¡¡|dd� t| ||t  	|¡¡|dd� t| ||t  	|¡¡|dd� t| ||t  	|¡¡|dd� t| ||t  	|¡¡|dd� t| ||t  	|¡¡|dd� t| | |t  	|¡¡|dd� t|  ||t  	|¡¡|dd� dS )z+Test photon luminosity density conversions.r–   r—   r˜   r™   rš   r›   rœ   r�   rž   rŸ   r    r¡   r¢   r£   r¤   rg   re   N)
r   r!   r    rƒ   rl   r¥   r#   r   r   r�   )	ZL_laZL_nuZ	phot_L_laZ	phot_L_nur¦   Zflux_phot_L_laZflux_phot_L_nuZ	flux_L_laZ	flux_L_nur   r   r   Útest_spectraldensity5ÿ  sv    



ýýýýýýýýýýr¨   c                  C   s¬   t jt jd t j t j t j  } t jt jd t j t j t j  }t  dddgt j¡}dddg}dd	d
g}t| 	| |t  
|¡¡|dd� t|  	||t  
|¡¡|dd� dS )z$Test surface brightness conversions.r   r–   r—   r˜   rŸ   r    r¡   r¢   r£   r¤   rg   re   N)r   r!   r   r    rƒ   Úsrrl   r#   r   r   r�   )ZslamZsnur¦   Zsb_flamZsb_fnur   r   r   Útest_spectraldensity6I  s    ""

rª   ©Z	from_unitZto_unitr   c              	   C   sp   t jtjdd��  |  |dt dtj ¡¡ W 5 Q R X t jtjdd��  | | dt dtj ¡¡ W 5 Q R X dS )zTNot allowed to succeed as
    per https://github.com/astropy/astropy/pull/10015
    r`   ra   r   N)r+   r,   r   rc   r   r�   rƒ   r«   r   r   r   Ú test_spectraldensity_not_allowedW  s    $r¬   c                  C   s¢   ddl m}  t | ¡�` tj ¡ }t|ƒ}tjtjtjtj	tj
tjtjtjtj| j| j| j| j| jh}||ksrt‚W 5 Q R X t|ƒ}| d¡t|ƒd ksžt‚d S )Nr   ©ÚimperialÚ
r   )Úastropy.unitsr®   r   Úadd_enabled_unitsr   Úfind_equivalent_unitsÚsetZM_eZM_prs   ZsolMassÚtZM_earthZM_jupZozZlbÚstZtonZslugr   ÚreprÚcountÚlen)r®   r   Z	units_setrb   Úrr   r   r   Útest_equivalent_unitsl  s,    
           ýrº   c                  C   s¢  t tj t ¡ ¡ƒ} tjtjtjtjtjtj	tj
tjtjtjtjtjtjtjtjtjtjtjtjh}| |kspt‚ddlm} t |¡�  t tj t ¡ ¡ƒ} tjtj|jtjtjtj|jtj	tj
tj|j|j|j|j tjtj|j!tj|j"tjtjtj|j#tjtj|j$tjtjtjh}| |k�s"t‚W 5 Q R X t tj t ¡ ¡ƒ} tjtjtjtjtjtj	tj
tjtjtjtjtjtjtjtjtjtjtjtjh}| |k�sžt‚d S )Nr   r­   )%r³   r   rl   r²   rn   ZAUZAngstromrm   ZRyr   rE   r!   ZlyrZlsecr?   rŒ   rj   ZsolRadZBqZCiÚkZearthRadZ
jupiterRadr   r°   r®   r±   ZBTUÚcalÚftZfurZinchZkcalÚmiÚmilZydZnmi)r   rb   r®   r   r   r   Útest_equivalent_units2}  sœ                    ý                        û                ýrÀ   c                   C   s(   t jjt jt jt jfgd�dks$t‚d S )Nr	   r   )r   r?   r   rs   r   r   r   r   r   Útest_trivial_equivalencyœ  s    rÁ   c                	   C   sb   t  t¡� tjjtjtjfgd� W 5 Q R X t  t¡�  tjjtjtjdfgd� W 5 Q R X d S )Nr	   g      @)r+   r,   Ú
ValueErrorr   r?   r   rs   r   r   r   r   Útest_invalid_equivalency   s    "rÃ   c                	   C   s8   t  tj¡�" tjjtjtjtjfgd� W 5 Q R X d S )Nr	   )r+   r,   r   r-   r?   r   rs   Úlr   r   r   r   Útest_irrelevant_equivalency¨  s    rÅ   c               	   C   s|   t jdtj d  } tjd }dtj }t j |jdtj	 j
tjtj|| d�d�¡ t j d|j
tj	tj|| d�d�¡ d S )	Né2   r   rV   çMû–Ù5@r   )Z	beam_arear	   r   )r.   Úpir   Úarcsecr7   ÚKr@   rA   r"   r”   r   Úbrightness_temperature)Úomega_BÚnuÚtbr   r   r   Útest_brightness_temperature­  s"    


 ÿþ ÿþrÏ   c               	   C   sª   t jdtj d  } tjd }dtj }t t¡�<}dtj	 j
tjt | |¡d�}|j
tj	t | |¡d�}W 5 Q R X t|ƒdks„t‚t j |j|j¡ t j |jd¡ dS )zT
    #5173 changes the order of arguments but accepts the old (deprecated) args
    rÆ   r   rV   rÇ   r   r	   N)r.   rÈ   r   rÉ   r7   rÊ   r+   Zwarnsr   r”   r   rË   r¸   r   r@   rA   r"   )rÌ   rÍ   rÎ   ÚwÚresultZ	roundtripr   r   r   Ú(test_swapped_args_brightness_temperature¿  s    

"rÒ   c                  C   sR   dt j t j } |  t jt  dt j ¡¡}tj 	|j
dd¡ |j t j¡sNt‚d S )NrÆ   g†æ:�´Ôä?rV   )r   ÚMJyr©   r   rÊ   rË   r7   r.   r@   rA   r"   Úunitri   r   )Úsbr»   r   r   r   Útest_surfacebrightnessÏ  s    rÖ   c                  C   sæ   dt j dtj d  } dtj  tjtj | ¡¡}t j	 
|  tj¡jd |j¡ |j tj¡sdt‚| tjtj | ¡¡}t j	 
|jd¡ dtj  dtj tj | ¡¡ dtj tj  tjtj tj | ¡¡}t j	 
|jd¡ d S )Nr   rÆ   rV   r   gò½‡äÈ+@)r.   rÈ   r   rÉ   Zbeamr   r©   r
   Zbeam_angular_arear@   rA   r"   rÔ   ri   r   r”   rÓ   )rÌ   Znew_beamZnbeamsZflux_densityr   r   r   Ú	test_beamÖ  s     
 
ÿr×   c                  C   st   dt j } dt j }t j| dt j d�}tj |jdt jt j	  j
t j|d�¡ tj d|j
t jt j	 |d�¡ d S )Né�   gGåÖ&Ï�e?gçû©ñÒÍ@)ZT_cmbr   r	   r   )r   r7   rÊ   Zthermodynamic_temperaturer.   r@   rA   r"   rÓ   r©   r   )rÍ   rÎ   Úeqr   r   r   Útest_thermodynamic_temperatureï  s    

 ÿrÚ   c            	   
      sH  t  t  ¡ ¡�ì t  dt j¡} tt d|  ¡dƒ t jdt j  }tt d| d t j	 ¡dƒ t
 t j¡� | jdd d� W 5 Q R X t  | t j¡}t|jt j t j¡ƒ G dd„ dtjƒ}t d¡ |¡}d|_t  |t j¡}t|jt j t j¡ƒ W 5 Q R X t  t  ¡ ¡�H t j t j¡ t j ¡ ‰ t
 t j¡� t jjt jd d� W 5 Q R X W 5 Q R X t j ¡ }t‡ fd	d
„|D ƒƒ�s‚t‚t|ƒtˆ ƒk �s˜t‚t  dt j ¡}dt j }|jt jt j |d�dt j t j k�sÞt‚t  |¡�V |dt j t j k�st‚t |dt j t j   t j¡ƒdt j t j k �s:t‚W 5 Q R X d S )Nr   y              ð?g      N@r   r	   c                   @   s   e Zd ZdS )z5test_equivalency_context.<locals>.MyQuantityLookalikeN)r   r   r   r   r   r   r   ÚMyQuantityLookalike  s   rÛ   r   c                 3   s   | ]}|t ˆ ƒkV  qd S rW   )r³   )Ú.0rÙ   ©Zeq_onr   r   Ú	<genexpr>  s     z+test_equivalency_context.<locals>.<genexpr>ip  iz  g      Y@g     @@)!r   r2   r   r#   r   r   r.   ÚexpÚminuteÚsecondr+   r,   r-   r   r   r"   r   Zndarrayr/   ÚviewrÔ   rn   r7   r   r²   r1   r   r³   Údoppler_opticalr�   r8   r    r3   )	r&   r%   rC   rÛ   ZmylookalikeÚq2Zeq_offZl2vÚl1r   rÝ   r   Útest_equivalency_contextù  s8     
&

,ræ   c               
   C   sŽ  t  ¡ } dd„ }|t  ¡ ƒ}|t  ¡ ƒ}t| jƒdks:t‚t  t  ¡ ¡��( t  ¡ }t||jƒƒt|ƒksnt‚t|j	ƒt| j	ƒks†t‚t  t  ¡ ¡�@ t  ¡ }t||jƒƒt|ƒks¸t‚t|j	ƒt| j	ƒksÐt‚W 5 Q R X t||jƒƒt|ƒksôt‚t|j	ƒt| j	ƒk�st‚t  
t  ¡ ¡�L t  ¡ }t||jƒƒt|ƒt|ƒB k�sJt‚t|j	ƒt| j	ƒk�sdt‚W 5 Q R X W 5 Q R X | t  ¡ k�sŠt‚d S )Nc                 S   s   dd„ | D ƒS )Nc                 S   s   g | ]}|d  |d f‘qS )r   r   r   )rÜ   Úequivr   r   r   Ú
<listcomp>*  s     zPtest_equivalency_context_manager.<locals>.just_to_from_units.<locals>.<listcomp>r   r	   r   r   r   Újust_to_from_units)  s    z<test_equivalency_context_manager.<locals>.just_to_from_unitsr   )r   Zget_current_unit_registryr   rn   r¸   r
   r   r2   r³   Z	all_unitsZadd_enabled_equivalencies)Zbase_registryré   Ztf_dimensionless_anglesZtf_spectralZnew_registryZnewer_registryr   r   r   Ú test_equivalency_context_manager&  s<    ÿ
ÿ
"ÿ
ÿþ.rê   c                  C   s  ddl m} m} dtj }t| tjt ¡ ¡dƒ t| | t ¡ ¡dƒ dtj }t| |t ¡ ¡dƒ d| }t| tjt ¡ ¡ddd	� d|  }t| |t ¡ ¡d
ƒ d| }t| | t ¡ ¡dƒ dtj }t| |t ¡ ¡dƒ d| }t| tjt ¡ ¡ddd	� d S )Nr   )Údeg_FÚdeg_RgfffffqÀg…ëQ¸º|Àé   g      B@g¸…ëQ8&@g{®Gáz„?)Zatolg…ëQ¸ú}@g…ëQ¸z{Àg�Âõ(\}€@g´Èv¾Ÿ`pÀ)	Zastropy.units.imperialrë   rì   r   rÊ   r   r   Zdeg_CZtemperature)rë   rì   Zt_kr   r   r   Útest_temperatureM  s     


rî   c                  C   sT   dt j } | tj  t j¡}t|  t jt  ¡ ¡|j	ƒ t| t jt  ¡ ¡| j	ƒ d S )NrS   )
r   rÊ   r   Zk_Br   ÚkeVr   r   Útemperature_energyr"   ©ÚxÚyr   r   r   Útest_temperature_energya  s    
rô   c               	   C   s|   dt jt j  } dt j  }t|  t j t  ¡ ¡|jƒ t| t jt j t  ¡ ¡| jƒ t t j	¡� |  
t j ¡ W 5 Q R X d S )Nr   )r   r   Zmolr   r   Zmolar_mass_amur"   r+   r,   r-   r   rñ   r   r   r   Útest_molar_mass_amuh  s    
 rõ   c               	   C   s*  t  d¡jt jft  ¡ d�} | d t jks.t‚t  d¡jt jft  ¡ d�} | d t  dt j ¡ksft‚t jjt  ¡ d�} t  t j t j	¡¡| ks”t‚t j
jt jt jft  dt j ¡d�} | D ]Z}|jt jt jgkr¼|jdd	gksät‚t|jt j
jt jt j t  dt j ¡d�ƒ  �q&q¼d
�s&tdƒ‚d S )NrÉ   )r   r
   r   z2 arcsecr   r	   gš™™™™™á?r   r[   Fz$Didn't find speed in compose results)r   ZUnitZcomposerj   rp   r   Zdegreer   r   r   rM   r?   r    rã   rŒ   ÚbasesZpowersr   Úscalerñ   r   r   r   Útest_compose_equivalenciesq  s&    
 ÿ"þrø   c                  C   sÔ   dt j } dt j }dt j t j }dt j t j }t|  t jt  |¡¡|ƒ t|  t jt  |¡¡|ƒ t|  t jt  |¡¡|ƒ t|  t jt  |¡¡|ƒ t| t jt  |¡¡| ƒ t| t jt  |¡¡| ƒ d S )NéK   rT   r€   r   )r   ÚpixrÉ   r   r   Úpixel_scaleÚarcmin)rú   ÚasecÚpixscaleÚ	pixscale2r   r   r   Útest_pixel_scaleŠ  s    

r   c               	   C   sn   dt j } dt j t jd  }tjt jdd�� t  | ¡ W 5 Q R X tjt jdd�� t  |¡ W 5 Q R X d S )Nr€   r   zpixel dimensionra   )r   rÉ   rú   r+   r,   r-   rû   )rþ   rÿ   r   r   r   Ú#test_pixel_scale_invalid_scale_unit›  s    
r  c                  C   sþ   dt j } dt jt j  }dt jt j t j  }dt jt jt j   }t|  t jt j t  |¡¡|ƒ t|  t jt j t  |¡¡|ƒ t|  t jt j t  |¡¡|ƒ t|  t jt j t  |¡¡|ƒ t| t jt  |¡¡| ƒ t| t jt  |¡¡| ƒ d S )Nrù   i¸  r€   r   )	r   rú   r   r    r?   r   r   rû   r8   )rú   Úvrþ   rÿ   r   r   r   Ú&test_pixel_scale_acceptable_scale_unit¥  s    
    r  c                  C   sÔ   dt j } dt j }dt j t j }dt j t j }t|  t jt  |¡¡|ƒ t|  t jt  |¡¡|ƒ t|  t jt  |¡¡|ƒ t|  t jt  |¡¡|ƒ t| t jt  |¡¡| ƒ t| t jt  |¡¡| ƒ d S )Ng      ø?rT   rí   gš™™™™™©?)r   ÚmmrÉ   r   r   Zplate_scalerü   )r  rý   Z
platescaleZplatescale2r   r   r   Útest_plate_scale¶  s    

r  c                  C   s¤   t  dt j t j ¡} t| tƒs$t‚t| jtƒs4t‚t	| jƒdksFt‚| jd dksXt‚t| j
tƒsht‚t	| j
ƒdkszt‚| j
d tddt j t j iƒks t‚d S )Nrw   r   r   rû   rþ   )r   rû   rÉ   rú   Ú
isinstancer   r   ÚnameÚlistr¸   ÚkwargsÚdict)Zpsr   r   r   Útest_equivelencyÇ  s    r  c                  C   s¨   t  dt j t j ¡t  ¡  } t| tƒs,t‚| jddgks>t‚t| j	t
ƒsNt‚| j	tddt j t j iƒtƒ gksvt‚t  dt j t j ¡dddg }t|t
ƒs¤t‚d S )Nrw   rû   rð   rþ   r   r   rf   )r   rû   rÉ   Zpixelrð   r  r   r   r  r	  r  r
  rú   )Úe1Úe2r   r   r   Útest_add_equivelenciesÒ  s    ( r  c                  C   sJ   t jj} t j ¡ }|  |¡ ¡ ddddddgks4t‚|  |¡dksFt‚d S )Nz/  Primary name | Unit definition | Aliases     ú[z1  Bq           | 1 / s           | becquerel    ,z1  Ci           | 3.7e+10 / s     | curie        ,z1  Hz           | 1 / s           | Hertz, hertz ,ú]a  <table style="width:50%"><tr><th>Primary name</th><th>Unit definition</th><th>Aliases</th></tr><tr><td>Bq</td><td>1 / s</td><td>becquerel</td></tr><tr><td>Ci</td><td>3.7e+10 / s</td><td>curie</td></tr><tr><td>Hz</td><td>1 / s</td><td>Hertz, hertz</td></tr></table>)	r   ZUnitBaseZEquivalentUnitsListrl   r²   Ú__repr__Ú
splitlinesr   Z_repr_html_)Zpprint_classZequiv_units_to_Hzr   r   r   Útest_pprintÝ  s    
ú
	ÿr  )ZÚ__doc__Únumpyr.   r+   Znumpy.testingr   Zastropyr   r   r   Zastropy.tests.helperr   Zastropy.units.equivalenciesr   Zastropy.utils.exceptionsr   r'   ÚmarkZparametrizeÚmagr0   ZdBr4   rã   Zdoppler_radioZdoppler_relativisticZdoppler_functionsr;   rD   rF   rL   rO   rQ   Z
values_ghzr  r�   rU   r”   Z
bad_valuesrX   r8   r    r?   r]   rd   rh   rv   r~   r‚   r„   r†   rˆ   rƒ   rŒ   rl   rm   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   Ú<module>   sÌ   






 ÿ
 ÿ
ýþ
Füþ	
 &ÿ
,]J*2*2üþ	

-'	
