
    IR-eq              
       z   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	 Zej                            d
e	j        e	j        e	j        f          d             Ze	j        e	j        e	j        gZej                            de          d             Zej                            de          d             Zej                            de          d             Zej                            de          d             Zej                            de          d             Zej                            de          d             Z dZ!ej                            d e" e#ee!                              d             Z$dde	j%        z  dfZ&ej                            d e" e#ee&                              d             Z'ej                            ddde	j(        e	j)        z  z  fdde	j*        e	j)        z  z  fdde	j*        e	j)        z  z  fg          d             Z+d Z,d Z-d  Z.d! Z/d" Z0d# Z1d$ Z2d% Z3ej                            d&g d'e	j4        fg d(e	j5        dz  fg d)e	j6        fg d*e	j7        fg          d+             Z8ej                            d,d-e	j4        z  d.e	j6        z  d/d-e	j4        z  z  d0e	j7        z  f          d1             Z9d2 Z:d3 Z;d4 Z<d5 Z=ej                            d6e	j>        e	j?        d7z  z  e	j)        z  e	j?        e	j?        z  e	j)        z  dz  fe	j>        e	j?        d7z  z  e	j)        z  e	j@        e	j?        e	j?        z  e	j)        z  e	jA        z  z  fe	j@        e	j?        d7z  z  e	j)        z  e	j?        e	j?        z  e	j)        z  dz  fe	j@        e	j?        d7z  z  e	j)        z  e	j@        e	j?        e	j?        z  e	j)        z  e	jA        z  z  fg          d8             ZBd9 ZCd: ZDd; ZEd< ZFd= ZGd> ZHd? ZId@ ZJdA ZKdB ZLdC ZMdD ZNdE ZOdF ZPdG ZQdH ZRdI ZSdJ ZTdK ZUdL ZVdM ZWdN ZXdO ZYdS )Pz.Separate tests specifically for equivalencies.    N)assert_allclose)	constants)units)assert_quantity_allclose)Equivalency)AstropyDeprecationWarningc                  H   t          j                    t           j                            d          dk    sJ t           j                            d          t           j                            t           j                  k    sJ t           j                            d          dk    sJ t           j                            t           j                  dk    sJ dt           j        z                      d          dk    sJ dt           j        z                      d          t           j                            t           j                  k    sJ dt           j        z                      d          dk    sJ dt           j	        z  t           j
        dz  z  } t           j        dt           j        z  z  }d| z  |dz  z  }|                    t           j                  }t          |j        |t           j        dz  z                      t           j                              G fddt           j                  } |dt           j                  }|                    d          t           j                            t           j                  k    sJ d S )	N   equivalencies      ?g\CkFI         ?c                       e Zd Z ZdS ))test_dimensionless_angles.<locals>.MyRad1N)__name__
__module____qualname___equivalencies)rad1s   Flib/python3.11/site-packages/astropy/units/tests/test_equivalencies.pyMyRad1r   (   s            r   )udimensionless_anglesradiantodegrad	steradiandimensionless_unscaledto_valuegcmcyclesergr   valueQuantity)IOmegaErotErot_in_erg1r   phaser   s         @r   test_dimensionless_anglesr/      s=    !##D8;;q;--4444588AT8**aehhquoo====;>>!4>00C7777#&&q{$&GG3NNNN!(N$$Qd$;;sBBBB!%K!!!4!88AEHHQUOOKKKK!+'''>>#EEEEqtQwAGsQSy!E7UAXD7715755LL&!);(E(Eae(L(LMMM          F3  E>>!

18 4 4444444r   log_unitc           	         t          j        t          j                  5  |                     dd           d d d            n# 1 swxY w Y   t          j        t          j                  5  t          j                            |            d d d            n# 1 swxY w Y   |                     ddt          j                              dk    sJ t          j                            | t          j                              dk    sJ t          j        g d          t          j	        z  }d|j
        z  t          j        z  }|                    |           }t          j        |                    dt          j                              |k              sJ t          j        |                    | t          j                              |k              sJ t          j        t          j                              5  t          j        t          j        ||                    |           z
            d| z  k               sJ 	 d d d            d S # 1 swxY w Y   d S )Nr
           r   r   )r2   g      r          @      $@g|=)pytestraisesr   
UnitsErrorr   r!   logarithmicnparraydexr(   allset_enabled_equivalenciesabs)r0   q_dex
q_expected
q_log_units       r   test_logarithmicrB   /   s    
q|	$	$  As              	q|	$	$ . .	 ##H---. . . . . . . . . . . . . . . ;;q#Q]__;==DDDD#&&xq}&OOSVVVVV H***++ae3Eu{"Q%==J(##J6*---AAZOPPPPP6*---HHJVWWWWW	
	$Q]__	5	5 Y YvbfZ*--*A*AABBWxEWWXXXXXXY Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Ys6   AA	A+ BBB=AIIIfunctionc                     dt           j        z  }|                    t           j        t           j        z   | |                    }|j        dk    sJ d S )Nq=
ף@Z@r   r   )r   GHzr   kmr&   r(   )rC   restvelo0s      r   test_doppler_frequency_0rJ   G   sK    AE>DGGAD13JhhtnnG==E;!r   c                     dt           j        z  }dt           j        z  }|                    t           j        t           j        z   | |                    }t          j                            |j	        dd           d S )NrE   g]Z%cg?r   r      decimal)
r   rF   mr   rG   r&   r9   testingassert_almost_equalr(   rC   rH   q1rI   s       r   test_doppler_wavelength_0rT   N   sc    AE>D	AC	BEE!$*HHTNNE;;EJ""5;1"=====r   c                     dt           j        z  }dt           j        z  }|                    t           j        t           j        z   | |                    }t          j                            |j	        dd           d S )NrE   g)v<?r   r   rL   rM   )
r   rF   eVr   rG   r&   r9   rP   rQ   r(   rR   s       r   test_doppler_energy_0rW   V   sc    AE>D		%BEE!$*HHTNNE;;EJ""5;1"=====r   c                 \   dt           j        z  }dt           j        z  }|                    t           j        t           j        z   | |                    }|                    t           j         | |                    }t
          j                            |j        |j        d           d S NrE   gRAZ@r      rM   )	r   rF   r   rG   r&   r9   rP   rQ   r(   )rC   rH   shiftedvelofreqs        r   test_doppler_frequency_circler^   ^   s    AE>DqunG::adQSj:??D7715777DJ""4:w}a"HHHHHr   c                 \   dt           j        z  }dt           j        z  }|                    t           j        t           j        z   | |                    }|                    t           j         | |                    }t
          j                            |j        |j        d           d S rY   )	r   nmr   rG   r&   r9   rP   rQ   r(   )rC   rH   r[   r\   wavs        r   test_doppler_wavelength_circlerb   g   s    AD=DqtmG::adQSj:??D
''!$hhtnn'
5
5CJ""39gmQ"GGGGGr   c                 \   dt           j        z  }dt           j        z  }|                    t           j        t           j        z   | |                    }|                    t           j         | |                    }t
          j                            |j        |j        d           d S )Ng>yX5?g o_?r   rZ   rM   )	r   rV   r   rG   r&   r9   rP   rQ   r(   )rC   rH   r[   r\   ens        r   test_doppler_energy_circlere   p   s    AD=DqtmG::adQSj:??D	XXd^^	4	4BJ""28W]A"FFFFFr   )gf'3?@g3?@gos3?@rC   r(   c                     dt           j        z  }dt           j        z  t           j        z  }|                    t           j         | |                    }t
          j                            |j        |d           d S )N     r   rZ   rM   )	r   rF   rG   r&   r   r9   rP   rQ   r(   )rC   r(   rH   r\   r[   s        r   
test_30kmsrj   |   sd     !%<D9qs?Dggae88D>>g::GJ""7=%"CCCCCr      c                     t          j        t          j                  5   | |           d d d            d S # 1 swxY w Y   d S N)r5   r6   r   r7   rf   s     r   test_bad_restfreqsrn      s     
q|	$	$                   s   8<<)zrv_ansgMbP?geT?IAg   Jxޱc                 B   | t           j        z  }|                    t           j        t           j        z  t          j                              }|                    t           j        t          j                              }t          ||           t          ||           d S rm   )r   r!   r   rG   r&   doppler_redshiftr   )ro   rp   z_inrv_outz_outs        r   test_doppler_redshiftrw      sz     q''DWWQTACZ!3!5!566FIIa.0B0D0DEEEVV,,,UD)))))r   c                     ddl m}  t          j        t          j        d          5  dt          j        t          j        z  z                      | t	          j	                               d d d            d S # 1 swxY w Y   d S )Nr   redshiftnot convertiblematch)
astropy.cosmology.unitsrz   r5   r6   r   UnitConversionErrorrG   r&   r   rs   ry   s    r   "test_doppler_redshift_no_cosmologyr      s    000000	q,4E	F	F	F > >	
adQSj	h(:(<(<===> > > > > > > > > > > > > > > > > >s   AA66A:=A:c                  F   t          j        g dt           j                  } t          j        g dt           j                  }t	          j        |                     t           j        t          j                              |j        d          sJ t	          j        |                    t           j        t          j                              | j        d          sJ t          j        dt           j        t           j	        dz  z            }t          j        dt           j        t           j
        dz  z            }t	          j        |                    t           j        t           j
        dz  z  t          j                              |j        d          sJ t	          j        |                    t           j        t           j	        dz  z  t          j                              |j        d          sJ t          j        dt           j        t           j	        d	z  z            }t          j        d
t           j        t           j
        d	z  z            }t	          j        |                    t           j        t           j
        d	z  z  t          j                              |j        d          sJ t	          j        |                    t           j        t           j	        d	z  z  t          j                              |j        d          sJ t          j        dt           j        t           j        z            }t          j        dt           j        t           j        z            }t	          j        |                    t           j        t           j        z  t          j                              |j        d          sJ t	          j        |                    t           j        t           j        z  t          j                              |j        d          sJ d S )N)gˡE[0Ag   rAg   P Ag   0AtKF)gAR:gQ5- ;gT2 ;gKo%:r
   r   gHz>rtolr   r   g-C6?   ư>r
   )r   r)   rV   r#   r9   allcloser"   mass_energyr(   rO   r$   r&   )mass_eVmass_gsdens_eVsdens_gdens_eVdens_gpow_eVpow_gs           r   test_massenergyr      st    jSSS	 G ZMMMqs F ;AMOO<<flQU      ;AMOO<<gmRV      z*AD136M::HjqsQT1W}--G;!#a-q}GG     
 ;QamooFF      j)14!#q&=99GZacAD!Gm,,F;qtQwamooFF     
 ;qsAvQ]__EE      Z(!$*55FJq!#)$$E;ac	AA     
 ;qtaczAA       r   c                  n   t           j                            t           j                  sJ t           j                            t           j                  sJ t           j                            t           j                  rJ t           j                            t           j        t          j                              sJ t           j                            t           j	                  rJ t           j                            t           j	        t          j
                              sJ t           j	                            t           j        t          j
                              sJ t           j                            t           j        t          j                              sJ t           j                            t           j        t          j                              sJ t           j                            t           j        t           j        t           j        f          sJ t           j                            t           j        t           j        t           j        f          sJ t           j                            t           j        t           j        t           j        f          sJ t           j                            t           j        t           j        t           j        f          rJ t           j        t           j        z                      t           j        t           j        t           j        f          rJ d S rm   )r   rO   is_equivalentpcr%   masr!   r   HzJspectral	arcsecondparallax	arcminuteaur$   r&   kgmsr#   LrG    r   r   test_is_equivalentr      s   3QT"""""7  '''''w$$Q%=>>>>>7  !91;Q;S;STTTTT""13''(((4ac1:<<000003QT1:<<000004ak1:<<88888;$$QT1:<<88888 4qsAC./////4qsAC./////3ac13-.....s  !#qsAD!122222qs
))13QT*:;;;;;;;r   c                     t           j                            t           j        dt          j                              } t          | dd           t           j                            t           j        | t          j                              }t          |dd           t           j                            t           j        dt          j                              } t          | dd           t           j                            t           j        | t          j                              }t          |dd           dt           j        z                      t           j        t          j                              }t          j
        |j                  sJ dt           j        z                      t           j        t          j                              }t          j
        |          sJ d S )N
   皙?-q=r   r
   g^X~۪@rq   )r   r   r   r   r   r   r   r   r   r9   isnanr(   r"   )abvals      r   test_parallaxr     sH   	qtR..AAt'****	Q
--AAr((((	qtQ
--AA~G4444	Q
--AAqw''''://!$

-
-C8CI:

ajll
3
3C8C==r   c                      t           j                            t           j        ddgt          j                              } t          | ddgd           d S )Nr         @r   皙?r   r   )r   r   r   r   r   r   r   s    r   test_parallax2r     sD    	qtc3Z66AACyw//////r   c                     t           j                            t           j        dt          j                              } t          | d           t           j                            t           j        | t          j                              }t          |d           t           j                            t           j        dt          j                              } t          | d           t           j                            t           j        | t          j                              }t          |d           t           j                            t           j        dt          j                              } t          | d           t           j                            t           j        | t          j                              }t          |d           d S )Nr
   g'BbCgTЅBgIxޱA)r   AAr   r   r   r   MHzrO   )r   r   s     r   test_spectralr     s%   	a&&AA,---	a&&AAq	q!*,,''AA,---	q!*,,''AAq	qtQ
%%AA+,,,	Q
%%AAqr   c                  V   t           j                            t           j        dt          j                              } t          | d           t           j                            t           j        | t          j                              }t          |d           t           j                            t           j        dt          j                              } t           j                            t           j        | t          j                              }t           j                            t           j        dt          j                              }t          ||           t           j                            t           j        |t          j                              }t          | |           d S )Ni  goaP<r
   )r   r`   r   r   r   r   r   r   )r   r   cs      r   test_spectral2r   )  s   	S!*,,''AA,---	qtQ
%%AAs	a&&A	Q
%%A	Q
%%AAq	qtQ
%%AAqr   c                      t           j                            t           j        ddgt          j                              } t          | ddg           d S )Nrh   i   hr
Bg hr
B)r   r`   r   r   r   r   r   s    r   test_spectral3r   8  s@    	tTlAJLL11AA}566666r   )in_valin_unit)r   g     @g     @g     j@r3   r   )g}Ӻ Cg hr
Cr   )g3]=g#aP<g`P<c                 r   t           j        dz  t           j        t           j        z  g}g dg dg}t          ||          D ]u\  }}|                    || t          j                              }t          ||           |                    ||t          j                              }t          ||            vdS )z;Wave number conversion w.r.t. wavelength, freq, and energy.rq   r   )gd;,#AgS!)@ghtT!@N)r   micronr   zipr   r   r   )r   r   	out_unitsanswersout_unitansr   r   s           r   test_spectral4r   =  s     2qx!(23I G G GHGY00 # ##JJx663 KKajll336""""# #r   ra   i  g pz8XCr
   g.j$<c                 T   t           j        t           j        z  t           j        dz  z  t           j        z  }t           j        t           j        z  t           j        dz  z  t           j        z  }|                    |dt          j        |                     }t          |d           t           j        t           j        dz  z  t           j        z  }t           j	        t           j        dz  z  t           j        z  }|                    |dt          j        |                     }t          |d           |                    |dt          j        |                     }t          |d           t           j        t           j        z  t           j        z  }t           j        t           j        z  t           j        z  }|                    |dt          j        |                     }t          |d           |                    |dt          j        |                     }t          |d           d S )Nr   r
   gvQ{=g  &DBga=gmz}LB)
r   r'   angstromr$   r&   r   r   spectral_densityr   ph)ra   flambdafnur   f_intphot_intllambdalnus           r   test_spectraldensity2r   V  s   
 eaj 147*QS0G
%!$,q
 13
&C

31-c2233AA,--- EAD!GOac!EtadAg~#H1a05566AA|$$$E1a05566AA~&&& eaj 13&G
%!$,
C

31-c2233AA,---w1-c2233AA*+++++r   c                  *   t           j        } t           j        t           j        dz  z  t           j        z  t           j        z  }t          j        dt           j                  }t          | 	                    t           j        t           j        dz  z  t           j        z  t           j
        z  d          dd           t          | 	                    t           j        t           j        dz  z  t           j        z  dt          j        |dz                      d           t          | 	                    |dt          j        |                    d           t          |	                    t           j        dt          j        |                    d	           t          |	                    t           j        t           j        dz  z  t           j        z  dt          j        t          j        dt           j                                      d
           d S )Nr   r
   r   gQ@-(;r   r   gvIh%<=g7J;g}Ӻ Cr4   )r   Jyr'   r$   r&   r   r)   rF   r   r   r   r   )f_nuf_lambdaone_ghzs      r   test_spectraldensity3r   v  s   4D uqtQw$qx/H jAE""G DGGAEAD!GOac1AD8#>>LLL EAD!GOac!3a6HSU6V6V 	 	
 	
 		   #Q-?-H-HII   AD#Q-?-H-HII#   EAD!GOac!,QZAH-E-EFF 	 	
 	

 	    r   c            	      	   t           j        t           j        dz  t           j        z  t           j        z  z  } t           j        t           j        dz  t           j        z  t           j        z  z  }t           j        t           j        dz  t           j        z  t           j        z  z  }t           j        t           j        dz  t           j        z  t           j        z  z  }t          j        g dt           j                  }g d}g d}g d}g d}g d}	g d}
g d	}t          |	                    | |t          j
        |                    |d
           t          | 	                    ||t          j
        |                    |d
           t          |	                    ||t          j
        |                    |d
           t          |	                    ||t          j
        |                    |d
           t          |	                    t           j        |t          j
        |                    |	d
           t          t           j        	                    ||	t          j
        |                    |d
           t          |	                    ||t          j
        |                    |d
           t          |	                    ||t          j
        |                    |d
           t          |	                    ||t          j
        |                    |d
           t          |	                    ||t          j
        |                    |d
           t          |	                    | |t          j
        |                    |d
           t          | 	                    ||t          j
        |                    |d
           t          |	                    t           j        |t          j
        |                    |
d
           t          t           j        	                    ||
t          j
        |                    |d
           t          |	                    t           j        |t          j
        |                    |d
           t          t           j        	                    ||t          j
        |                    |d
           dS )zPHOTLAM and PHOTNU conversions.r   g\@ǧ_@gLb@g?g9gN?gu0:
?g6=g2)/7=g dE6=g<&=gC&=g	&=gs)N:g٭/8j:gZ7v:)gÖuk?g?gnx?)gHP(@gu&D(@g&h(@)g9)iD)@gx\C5)@ǵ17C)@r   r   N)r   r'   r$   r&   r   r   photonr)   r   r   r   r   STmagABmag)flamr   photlamphotnuwaveflux_photlamflux_photnu	flux_flamflux_fnuflux_jy
flux_stmag
flux_abmags               r   test_spectraldensity4r     s   5AD!GacMAD()D
%147QS=14'
(Ch!$'AC-!$./GXq13-.F:///66D777LBBBK444I???H;;;G888J888J 

4q'9$'?'?@@)RV    A$6t$<$<==|RV   
 

3a&8&>&>??PT    w!"4T":":;;\PT   
 

14q'9$'?'?@@'PT    	!"4T":":;;\PT   
 

6<);D)A)ABB   
 		';(:4(@(@AA    		#{A$6t$<$<==xd    vx!3D!9!9::Kd   
 		$Q%7%=%=>>	PT    	1#5d#;#;<<kPT   
 

17L!*<T*B*BCC   
 	

7J(:4(@(@AA    

17L!*<T*B*BCC   
 	

7J(:4(@(@AA     r   c            	         t           j        t           j        t           j        z  z  } t           j        t           j        t           j        z  z  }t           j        t           j        t           j        z  z  }t           j        t           j        t           j        z  z  }t          j        g dt           j                  }g d}g d}g d}g d}t          |                    | |t          j	        |                    |d           t          |                     ||t          j	        |                    |d           t          |                    ||t          j	        |                    |d           t          |                    ||t          j	        |                    |d           t          |                    ||t          j	        |                    |d           t          |                    ||t          j	        |                    |d           t          |                    ||t          j	        |                    |d           t          |                    ||t          j	        |                    |d           t          |                    | |t          j	        |                    |d           t          |                     ||t          j	        |                    |d           dS )	z+Test photon luminosity density conversions.r   r   r   r   r   r   r   N)
r   r'   r&   r   r   r   r)   r   r   r   )	L_laL_nu	phot_L_la	phot_L_nur   flux_phot_L_laflux_phot_L_nu	flux_L_la	flux_L_nus	            r   test_spectraldensity5r     s   5AC!$JD5AC!$JDAC!$J'IAC!$J'I:///66D999NEEEN444I@@@I T>1+=d+C+CDD   
 	9a&8&>&>??    T>1+=d+C+CDD   
 	9a&8&>&>??    Y0B40H0HII   
 Y0B40H0HII    T>1+=d+C+CDD   
 	9a&8&>&>??    T>1+=d+C+CDD   
 	9a&8&>&>??     r   c            	      H   t           j        t           j        dz  t           j        z  t           j        z  t           j        z  z  } t           j        t           j        dz  t           j        z  t           j        z  t           j        z  z  }t          j        g dt           j                  }g d}g d}t          |	                    | |t          j
        |                    |d           t          | 	                    ||t          j
        |                    |d           dS )z$Test surface brightness conversions.r   r   r   r   r   r   N)r   r'   r$   r&   r   srr   r)   r   r   r   )slamsnur   sb_flamsb_fnus        r   test_spectraldensity6r   I  s    5AD!GacMAD(14/0D
%147QS=14'!$.
/C:///66D222G===F CFF4);D)A)ABBGRVWWWWDGGC!*<T*B*BCCVRVWWWWWWr   	from_unitto_unitr   c           	         t          j        t          j        d          5  |                     |dt          j        dt          j        z                       ddd           n# 1 swxY w Y   t          j        t          j        d          5  |                    | dt          j        dt          j        z                       ddd           dS # 1 swxY w Y   dS )zTNot allowed to succeed as
    per https://github.com/astropy/astropy/pull/10015
    r{   r|   r
   N)r5   r6   r   r   r   r   r   r   s     r    test_spectraldensity_not_allowedr   W  s?    
q,4E	F	F	F ? ?Wa!3AH!=!=>>>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
q,4E	F	F	F ? ?

9a!3AH!=!=>>>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?s#   7A$$A(+A(7CCCc                  P   ddl m}  t          j        |           5  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    sJ 	 d d d            n# 1 swxY w Y   t'          |          }|                    d          t+          |          dz   k    sJ d S )Nr   imperial
r   )astropy.unitsr  r   add_enabled_unitsr#   find_equivalent_unitssetM_eM_pr   solMasstM_earthM_jupozlbsttonslugreprcountlen)r  r   	units_setr}   rs        r   test_equivalent_unitsr  l  s(   &&&&&&	
	X	&	& " "))++JJ	E15!#qtQYQS!)GX[(+x{HLM

 E!!!!!" " " " " " " " " " " " " " " 	UA774==CJJN******s   B9C!!C%(C%c                  t   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        t          j        t          j        h}| |k    sJ ddlm} t          j        |          5  t          t          j                            t          j                                        } 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J 	 d d d            n# 1 swxY w Y   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        t          j        t          j        h}| |k    sJ d S )Nr   r  )$r  r   r   r  r   AUAngstromr   Ryr$   rV   r'   lyrlsecrO   r   r   solRadBqCikearthRad
jupiterRadr  r  r  BTUcalftfurinchkcalmimilydnmi)r   r}   r  s      r   test_equivalent_units2r0  }  sD   **1:<<8899E	aj!$QT14quaeQV	QXqtQXqtQT13
	E
 E>>>>&&&&&&	
	X	&	& 	 	AD..qz||<<==D!*hlAD!#qtL!$aeX[(,M8=!%hk16L!(AD!(HKqtL!#qz1<
 ~~~~~	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 **1:<<8899E	aj!$QT14quaeQV	QXqtQXqtQT13
	E
 E>>>>>>s   3EJJJc                      t           j                            t           j        t           j        t           j        fg          dk    sJ d S )Nr   r   )r   rO   r   r   r   r   r   test_trivial_equivalencyr2    s7    366!$QT{m644;;;;;;r   c                     t          j        t                    5  t          j                            t          j        t          j        fg           d d d            n# 1 swxY w Y   t          j        t                    5  t          j                            t          j        t          j        dfg           d d d            d S # 1 swxY w Y   d S )Nr   g      @)r5   r6   
ValueErrorr   rO   r   r   r   r   r   test_invalid_equivalencyr5    s   	z	"	" - -	qtQSF8,,,- - - - - - - - - - - - - - - 
z	"	" 1 1	qtQS#J<0001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1s#   8AA"%A"9CCCc                      t          j        t          j                  5  t          j                            t          j        t          j        t          j        fg           d d d            d S # 1 swxY w Y   d S )Nr   )r5   r6   r   r7   rO   r   r   lr   r   r   test_irrelevant_equivalencyr8    s    	q|	$	$ 1 1	qtQS!#J<0001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1s   AA//A36A3c            
         t           j        dt          j        z  dz  z  } t          j        dz  }dt          j        z  }t           j                            |j        dt          j	        z  
                    t          j        t          j        ||                                t           j                            d|
                    t          j	        t          j        ||                                d S )	N2   r   rk   M5@r
   )	beam_arear   r   )r9   pir   arcsecrF   KrP   rQ   r(   r   r"   brightness_temperature)omega_Bnutbs      r   test_brightness_temperaturerD    s    erAH}**G	
B	QS	 BJ""
	
QTCq7gNNN 	 	
 	
   J""
D 8w O O O 	 	
 	
    r   c                     t           j        dt          j        z  dz  z  } t          j        dz  }dt          j        z  }t          j        t                    5 }dt          j	        z  
                    t          j        t          j        | |                    }|
                    t          j	        t          j        | |                    }ddd           n# 1 swxY w Y   t          |          dk    sJ 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   rk   r;  r
   r   N)r9   r=  r   r>  rF   r?  r5   warnsr   r   r   r@  r  rP   rQ   r(   )rA  rB  rC  wresult	roundtrips         r   (test_swapped_args_brightness_temperaturerJ    sF    erAH}**G	
B	QS	 B	/	0	0 YAad(qs!2J7TV2W2WXXIIad!2J7TV2W2WIXX	Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y q66Q;;;;J""28V\:::J""9?A66666s   A6CC Cc                  T   dt           j        z  t           j        z  } |                     t           j        t          j        dt           j        z                      }t          j        	                    |j
        dd           |j                            t           j                  sJ d S )Nr:  g:?rk   )r   MJyr   r   r?  r@  rF   r9   rP   rQ   r(   unitr   )sbr#  s     r   test_surfacebrightnessrO    sz    	aead	B
ac1+BJ7788AJ""17Ha8886$$$$$$$r   c                  .   dt           j        z  dt          j        z  dz  z  } dt          j        z                      t          j        t          j                            |                     }t           j	        
                    |                     t          j                  j        dz  |j                   |j                            t          j                  sJ |                    t          j        t          j                            |                     }t           j	        
                    |j        d           dt          j        z                      dt          j        z  t          j                            |                      dt          j        z  t          j        z                      t          j        t          j        z  t          j                            |                     }t           j	        
                    |j        d           d S )Nr   r:  rk   r
   g+@)r9   r=  r   r>  beamr   r   r   beam_angular_arearP   rQ   r(   rM  r   r   rL  )rA  new_beamnbeamsflux_densitys       r   	test_beamrV    sn   "%i2=Q..GAF
qtQ_%F%Fw%O%OPPHJ""7::ad#3#3#9A#=x~NNN=&&qt,,,,, [[!B!B7!K!KLLFJ""6<333
 ZOOAHao??HHIII Hqv%))	ao77@@ L J""<#57GHHHHHr   c                     dt           j        z  } dt           j        z  }t          j        | dt           j        z            }t          j                            |j        dt           j        t           j	        z  z  
                    t           j        |                     t          j                            d|
                    t           j        t           j	        z  |                     d S )N   gG&Ϗe?g@)T_cmbr
   r   r   )r   rF   r?  thermodynamic_temperaturer9   rP   rQ   r(   rL  r   r"   )rB  rC  eqs      r   test_thermodynamic_temperaturer\    s    	quB		$B	
	$Rv|	<	<	<BJ""
1%//2/FF   J""3AEADLPR(S(STTTTTr   c                  0	  	 t          j        t          j                              5  t          j        dt           j                  } t          t          j        d| z            d           t           j        dt           j        z  z  }t          t          j        d|z  dz  t           j	        z            d           t          j        t           j                  5  |                     dd            d d d            n# 1 swxY w Y   t          j        | t           j                  }t          |j        t           j                            t           j                              G d dt          j                  }t          j        d                              |          }d|_        t          j        |t           j                  }t          |j        t           j                            t           j                             d d d            n# 1 swxY w Y   t          j        t          j                              5  t           j                            t           j                   t           j                                        	t          j        t           j                  5  t           j                            t           j        d            d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t           j                                        }t3          	fd	|D                       sJ t5          |          t5          	          k     sJ t          j        d
t           j        z            }dt           j        z  }|                    t           j        t           j        z  |          dt           j        z  t           j        z  k    sJ t          j        |          5  |dt           j        z  t           j        z  k    sJ t?          |dt           j        z  t           j        z  z
                      t           j                            dt           j        z  t           j        z  k     sJ 	 d d d            d S # 1 swxY w Y   d S )Nr   y              ?g      N@r
   r   c                       e Zd ZdS )5test_equivalency_context.<locals>.MyQuantityLookalikeN)r   r   r   r   r   r   MyQuantityLookaliker_    s        Dr   r`  r%   c              3   :   K   | ]}|t                    v V  d S rm   )r  ).0r[  eq_ons     r   	<genexpr>z+test_equivalency_context.<locals>.<genexpr>  s.      11BrSZZ111111r   ip  iz  g      Y@g     @@) r   r=   r   r)   r%   r   r9   expminutesecondr5   r6   r7   r   r!   r(   r   ndarrayr:   viewrM  r   rF   r$   r  r<   r  doppler_opticalr   rG   r&   r>   )
r.   r+   rS   r`  mylookalikeq2eq_offl2vl1rc  s
            @r   test_equivalency_contextrp    s   	
	$Q%;%=%=	>	> 8 8
3((rEz**C0003>*rEzD018;<<cBBB]1<(( 	, 	,HHQdH+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, Zq788!'**QX"6"6777	 	 	 	 	"* 	 	 	 hsmm(()<=="ZQ%=>>!'**QX"6"6777+8 8 8 8 8 8 8 8 8 8 8 8 8 8 8. 
	$QZ\\	2	2 / /	++--]1<(( 	/ 	/EHHQTH...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	// / / / / / / / / / / / / / / U((**F1111&11111111v;;U#### 
D1:-
.
.C	
	B5535//%!$,2DDDDD	
	$S	)	) P PEADL13&&&&&B++//
;;<<sQTzAC?OOOOOOP P P P P P P P P P P P P P P P P Ps   B4HC?3H?D	HD	C?HHHA&K7(,K K7 K$	$K7'K$	(K77K;>K;1BRRRc                     t          j                    } d } |t          j                              } |t          j                              }t	          | j                  dk    sJ t          j        t          j                              5  t          j                    }t           ||j                            t          |          k    sJ t          |j                  t          | j                  k    sJ t          j        t          j                              5  t          j                    }t           ||j                            t          |          k    sJ t          |j                  t          | j                  k    sJ 	 d d d            n# 1 swxY w Y   t           ||j                            t          |          k    sJ t          |j                  t          | j                  k    sJ t          j	        t          j                              5  t          j                    }t           ||j                            t          |          t          |          z  k    sJ t          |j                  t          | j                  k    sJ 	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   | t          j                    u sJ d S )Nc                     d | D             S )Nc                 .    g | ]}|d          |d         fS )r   r
   r   )rb  equivs     r   
<listcomp>zPtest_equivalency_context_manager.<locals>.just_to_from_units.<locals>.<listcomp>*  s%    @@@q58$@@@r   r   r   s    r   just_to_from_unitsz<test_equivalency_context_manager.<locals>.just_to_from_units)  s    @@-@@@@r   r
   )
r   get_current_unit_registryr   r   r  r   r=   r  	all_unitsadd_enabled_equivalencies)base_registryrv  tf_dimensionless_anglestf_spectralnew_registrynewer_registrys         r    test_equivalency_context_managerr  &  s   /11MA A A 101G1I1IJJ$$QZ\\22K }*++q0000	
	$Q%;%=%=	>	> Q Q244%%l&@AABBc#G
 G
 
 
 
 
 <)**c-2I.J.JJJJJ(66 	Q 	Q8::N)).*FGGHHCM M     ~/00C8O4P4PPPPPP	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q %%l&@AABBc#G
 G
 
 
 
 
 <)**c-2I.J.JJJJJ(66 	Q 	Q8::N)).*FGGHHC'M MK  M! ! ! ! ! ~/00C8O4P4PPPPPP	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q#Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q0 A799999999s^   BK#A0F K F$	$K'F$	(BK,B J9-K9J=	=K J=	KKKc                  ,   ddl m} m} dt          j        z  }t          |                    t          j        t          j                              d           t          |                    | t          j                              d           dt          j        z  }t          |                    |t          j                              d           d|z  }t          |                    t          j        t          j                              dd	           d| z  }t          |                    |t          j                              d
           d|z  }t          |                    | t          j                              d           dt          j        z  }t          |                    |t          j                              d           d|z  }t          |                    t          j        t          j                              dd	           d S )Nr   )deg_Fdeg_RgfffffqgQ|   g      B@gQ8&@g{Gz?)atolgQ}@gQz{g(\}@gv`p)	astropy.units.imperialr  r  r   r?  r   r"   deg_Ctemperature)r  r  t_ks      r   test_temperaturer  M  s   33333333
ac'CCLL!-//::GDDDCLL88'BBB
qs(CCLL88$???
u*CCLLamoo66DIIII
u*CCLL88&AAA
u*CCLL88'BBB
qw,CCLL88&AAA
u*CCLL!-//::H4PPPPPPr   c                     dt           j        z  } | t          j        z                      t           j                  }t          |                     t           j        t          j                              |j	                   t          |                    t           j        t          j                              | j	                   d S )Nrh   )
r   r?  r   k_Br   keVr   r"   temperature_energyr(   xys     r   test_temperature_energyr  a  s    qs
A	
Y]	qu%%AAJJqua&:&<&<==qwGGGAJJqsA$8$:$:;;QWEEEEEr   c                  2   dt           j        t           j        z  z  } dt           j         z  }t          |                     t           j         t          j                              |j                   t          |                    t           j        t           j        z  t          j                              | j                   t          j        t           j	                  5  | 
                    t           j                    d d d            d S # 1 swxY w Y   d S )Nr
   )r   r#   molr   r"   molar_mass_amur(   r5   r6   r7   r   r  s     r   test_molar_mass_amur  h  s   	QS15[A	ACAAJJqsA$4$6$677AAAAJJqsQU{A,<,>,>??III	q|	$	$  	QS			                 s    DDDc                     t          j        d                              t           j        ft          j                              } | d         t           j        k    sJ t          j        d                              t           j        ft          j                              } | d         t          j        dt           j        z            k    sJ t           j                            t          j                              } t          j        t           j                            t           j                            | v sJ t           j	                            t           j
        t           j        ft          j        dt           j        z                      } | D ]}|j        t           j
        t           j        gk    r||j        dd	gk    sJ t!          |j        t           j	                            t           j
        t           j        z  t          j        dt           j        z                                  d S J d            )Nr>  )r   r   r   z2 arcsecr   r   g?r
   rq   Fz$Didn't find speed in compose results)r   Unitcomposer   r   degreer   r   r   r`   rO   r&   rj  r   basespowersr   scaler  s     r   test_compose_equivalenciesr  q  s   	x  wajll KKAQ414<<<<	z""!$
"MMAQ416#*%%%%%%	q'='?'?@@A6!(++ah''((A----	
sACj(9$/(J(J 	 	 	A  	= 	=7qsACj  82w&&&&ac	1B4!(?1S1STT   EE ! 	=<<<<r   c                     dt           j        z  } dt           j        z  }dt           j        z  t           j        z  }dt           j        z  t           j        z  }t          |                     t           j        t          j        |                    |           t          |                     t           j        t          j        |                    |           t          |                     t           j        t          j        |                    |           t          |                     t           j        t          j        |                    |           t          |                    t           j        t          j        |                    |            t          |                    t           j        t          j        |                    |            d S )NK   ri   r   r   )r   pixr>  r   r   pixel_scalearcmin)r  asecpixscale	pixscale2s       r   test_pixel_scaler    s>   
qu*C=DQX~%Haeah&ISVVAHamH.E.EFFMMMSVVAHamH.E.EFFMMMSVVAHamI.F.FGGNNNSVVAHamI.F.FGGNNNTWWQUAM(,C,CDDcJJJTWWQUAM),D,DEEsKKKKKr   c                     dt           j        z  } dt           j        z  t           j        dz  z  }t          j        t           j        d          5  t          j        |            d d d            n# 1 swxY w Y   t          j        t           j        d          5  t          j        |           d d d            d S # 1 swxY w Y   d S )Nr   r   zpixel dimensionr|   )r   r>  r  r5   r6   r7   r  )r  r  s     r   #test_pixel_scale_invalid_scale_unitr    s,   QX~Hah)I	q|+<	=	=	=    	h                             	q|+<	=	=	= ! !	i   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !s$   A00A47A4B==CCc                  h   dt           j        z  } dt           j        t           j        z  z  }dt           j        t           j        z  t           j        z  z  }dt           j        t           j        t           j        z  z  z  }t          |                     t           j        t           j        z  t          j        |                    |           t          |                     t           j        t           j        z  t          j        |                    |           t          |                     t           j        t           j        z  t          j        |                    |           t          |                     t           j        t           j        z  t          j        |                    |           t          |                    t           j        t          j        |                    |            t          |                    t           j        t          j        |                    |            d S )Nr  i  r   r   )	r   r  r$   r&   rO   r   r   r  rG   )r  vr  r  s       r   &test_pixel_scale_acceptable_scale_unitr    sk   
qu*Cqs
AacACi!%'(Hquac	*+ISVVAC!#Iq}X/F/FGGKKKSVVAD13Jh0G0GHH!LLLSVVAC!#Iq}Y/G/GHH!LLLSVVAD13Ji0H0HII1MMMQTT!%x)@)@AA3GGGQTT!%y)A)ABBCHHHHHr   c                     dt           j        z  } dt           j        z  }dt           j        z  t           j        z  }dt           j        z  t           j        z  }t          |                     t           j        t          j        |                    |           t          |                     t           j        t          j        |                    |           t          |                     t           j        t          j        |                    |           t          |                     t           j        t          j        |                    |           t          |                    t           j        t          j        |                    |            t          |                    t           j        t          j        |                    |            d S )Ng      ?ri   r  g?)r   mmr>  r   r   plate_scaler  )r  r  
platescaleplatescale2s       r   test_plate_scaler    s>   	qtB=Dah%J+(KRUU18Q]:-F-FGGNNNRUU18Q]:-F-FGGNNNRUU18Q];-G-GHH$OOORUU18Q];-G-GHH$OOOTWWQT1=+D+DEErJJJTWWQT1=+E+EFFKKKKKr   c                     t          j        dt           j        z  t           j        z            } t	          | t
                    sJ t	          | j        t                    sJ t          | j                  dk    sJ | j        d         dk    sJ t	          | j	        t                    sJ t          | j	                  dk    sJ | j	        d         t          ddt           j        z  t           j        z  i          k    sJ d S )Nr   r
   r   r  r  )r   r  r>  r  
isinstancer   namelistr  kwargsdict)pss    r   test_equivelencyr    s    	
rAH}qu,	-	-Bb+&&&&&bgt$$$$$rw<<171:&&&&bi&&&&&ry>>Q9Q<4R!(]QU-B CDDDDDDDDr   c                  *   t          j        dt           j        z  t           j        z            t          j                    z   } t          | t                    sJ | j        ddgk    sJ t          | j        t                    sJ | j        t          ddt           j        z  t           j        z  i          t                      gk    sJ t          j        dt           j        z  t           j        z            g dz   }t          |t                    sJ d S )Nr   r  r  r  )r
   r   r   )r   r  r>  pixelr  r  r   r  r  r  r  r  )e1e2s     r   test_add_equivelenciesr    s    	
rAH}qw.	/	/!2F2H2H	HBb+&&&&&7}&:;;;;;bi&&&&&9z2=15+@ABBDFFKKKKK	
rAH}qw.	/	/)))	;Bb$r   c                      t           j        j        } t           j                                        }|                     |                                          g dk    sJ |                     |          dk    sJ d S )N)z/  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   UnitBaseEquivalentUnitsListr   r  __repr__
splitlines_repr_html_)pprint_classequiv_units_to_Hzs     r   test_pprintr    s    :1L2244  !233>>@@ E E E     	  !233 8J 	J 	J 	J 	J 	J 	Jr   )Z__doc__numpyr9   r5   numpy.testingr   astropyr   r   r   astropy.tests.helperr   astropy.units.equivalenciesr   astropy.utils.exceptionsr   r/   markparametrizemagr;   dBrB   rj  doppler_radiodoppler_relativisticdoppler_functionsrJ   rT   rW   r^   rb   re   
values_ghzr  r   rj   r   
bad_valuesrn   rG   r&   rO   rw   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r$   r'   r  r   r  r0  r2  r5  r8  rD  rJ  rO  rV  r\  rp  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   <module>r     sh   4 4      ) ) ) ) ) )             9 9 9 9 9 9 3 3 3 3 3 3 > > > > > >5 5 5: aeQUAD%9::Y Y ;:Y( &9OP  %677  87 %677> > 87> %677> > 87> %677I I 87I %677H H 87H %677G G 87G F
 44$5z B BCC D D D QT4 
 44$5z B BCC   
 	
A	139-.	]acACi() * * *> > >C C CL< < <&  $0 0 0
  "  7 7 7
 			&	!(B,'	6	6	6=	9	9	913?	 # # #  	D14K,a4!$;.?RSRUAUV , , ,:) ) )XZ Z ZzG G GTX X X 	
a!#	qtac 1b89	
a!#	quqtac(9AE(ABC	
q13	qs!2r 9:	
q13	qs):QU)B CD	 	? 	? 	?+ + +"  >< < <1 1 11 1 1
  $7 7 7 % % %I I I2U U U*P *P *PZ$: $: $:NQ Q Q(F F F  = = =2L L L"! ! !I I I"L L L"E E E         r   