
    IR-e[~                        d dl Z d dlZd dlmZ d dlZd dlZd dlmZm	Z	 d dlm
Z d dlmZmZ d dlmZ d dlmZ d dlmZmZmZmZmZmZmZmZ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l'm(Z( ddl)m*Z* d Z+d Z,d Z-d Z.d Z/ej0        j1        ej0        2                    deef          d                         Z3ej0        2                    deef          d             Z4d Z5d Z6d Z7d Z8d Z9d Z:d Z;ej0        2                    d d!d"g          d#             Z<d$ Z=d% Z>d& Z?d' Z@d( ZAd) ZBd* ZCd+ ZDd, ZEd- ZFej0        2                    d.d!d"g          d/             ZGd0 ZHd1 ZId2 ZJd3 ZKd4 ZLej0        2                    d d!d"g          ej0        2                    d5eeg          d6                         ZMd7 ZNdS )8    N)StringIO)coordinatestime)units)EarthLocationSkyCoord)skycoord_equal)representation_equal)	ColumnNdarrayMixinQTableTablehstackjoin	serializetable_helpersvstack)
BaseColumn)represent_mixins_as_columns)ArrayWrapper)ParentDtypeInfo)AstropyUserWarning)MergeConflictWarning   )
MIXIN_COLSc           	         | d         }d|j         _        |j         j        dk    sJ d|j         _        |j         j        dk    sJ t          |t          j        t          j        t          j	        t          j
        t          j        t          j        f          rHt          j        t                    5  t          j        |j         _        ddd           n# 1 swxY w Y   n0t          j        |j         _        |j         j        t          j        u sJ d|j         _        |j         j        dk    sJ ddi|j         _        |j         j        ddik    sJ t          j        t                    5  d|j         _        ddd           n# 1 swxY w Y   t          j        t                    5  |j         j         ddd           dS # 1 swxY w Y   dS )z6
    Required attributes for a column can be set.
    maNr   )infonamedescription
isinstanceuQuantityr   r   r   Time	TimeDelta BaseRepresentationOrDifferentialStokesCoordpytestraisesAttributeErrorr   unitformatmetabad_attr)
mixin_colsr   s     >lib/python3.11/site-packages/astropy/table/tests/test_mixin.pytest_attributesr2   %   sP    	3AAFK6;#AF6$$$$ 	J IN8#	

 
 " ]>** 	 	#AFK	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 cv{ac!!!!AFM6=C(AFK6;3(""""	~	&	&                 
~	&	&  	                 s6   0CCC(FFF%F??GGc                 (   t          |j        t          j                  rt	          |           t
          ust          |t                    rt	          |          | j        u sJ n t	          |          t	          |          u sJ |j        j        J d S N)	r"   r   r#   QuantityInfotyper   r   ColumnClassr    )table	table_colin_cols      r1   check_mixin_typer;   O   s    
 	6;///48KKv4M4M	FF	#	# 5NI%"333333I$v,,.... ;#####    c                 x   |                      |          }t          ||d         |d                    t          |                                          }|                      |d          }t          ||d         |d                    |                      |          }t          ||d         |d                    dS )z
    Make a table with the columns in mixin_cols, which is an ordered dict of
    three cols: 'a' and 'b' are table_types.Column type, and 'm' is a mixin.
    r   )ir   br   namescol3N)r   r;   listvalues)table_typesr0   tcolss       r1   test_make_tablerH   ^   s    
 	*%%AQ#
3000
!!##$$D$&:;;AQ#
3000$AQ&	:c?33333r<   c                      ddl m}  t          t                    } |             D ]?}|d         r5d|d         vr+t	                      }|                    ||d                    @dS )z
    Test that table with mixin column can be written by io.ascii for
    every pure Python writer.  No validation of the output is done,
    this just confirms no exceptions.
    r   )_get_connectors_tableWritez.fast_Formatr-   N)astropy.io.ascii.connectrJ   r   r   r   write)rJ   rF   fmtouts       r1   test_io_ascii_writerR   n   s     ?>>>>>zA$$&& / /w< 	/HCM99**CGGCHG.../ /r<   c                 (   t                      }t          j        g dd          |d<   | dz  }|                    |dd           t          j        |d	          }t          |d         t          j                  sJ |d         j        dk    sJ d
S )a  
    Test that table with Quantity mixin column can be round-tripped by
    io.votable.  Note that FITS and HDF5 mixin support are tested (much more
    thoroughly) in their respective subpackage tests
    (io/fits/tests/test_connect.py and io/misc/tests/test_hdf5.py).
    )r         nmr,   r   	table-tmpvotableTr-   	overwriterM   N)r   r#   r$   rO   readr"   r,   )tmp_pathrF   filenameqts       r1   test_votable_quantity_writer`   }   s     	AZ			---AcF+%HGGHY$G777	Xi	0	0	0Bbgqz*****c7<4r<   rE   c                     |ddgddgg          }t           j        D ]U}t          j        ddgddggd|t          dd	d
d                    |d|z   <   t          j        ddg|          |d|z   <   Vddg|d<   | dz  }t	          j        t          d          5  |                    |dd           ddd           n# 1 swxY w Y   t	          j        t          d          5  |                    |dd          }ddd           n# 1 swxY w Y   t           j        D ]}dD ]}||z   }t          ||         t           j                  sJ ||         j
        ||         j
        k    sJ ||         j        d k    sJ ||         j        ||         j        k    sJ ||         ||         k                                    sJ d!D ]E}t          ||         t                    sJ ||         ||         k                                    sJ Ft           j        D ]!}dD ]}||z   }d"||         j        j        d<   "|                    |dd           |                    |d#          }t           j        D ]Y}dD ]T}||z   }t          ||         t           j                  rJ ||         ||         j        k                                    sJ UZdS )$a}  
    Test that table with Time mixin columns can be written by io.fits.
    Validation of the output is done. Test that io.fits writes a table
    containing Time mixin columns that can be partially round-tripped
    (metadata scale, location).

    Note that we postpone checking the "local" scale, since that cannot
    be done with format 'cxcsec', as it requires an epoch.
    r   rT   stringcolumn   rU   cxcsec隧@ 9> r   rW   r-   scalelocationr   1999-01-01T00:00:00.1234567892010-01-01T00:00:00rj   r?         @      @crX   zQTime Column "btai" has no specified location, but global Time Position is presentmatchfitsTrZ   Nz8Time column reference position "TRPOSn" is not specifiedr-   astropy_nativer   r?   jdcol0col1rq   formatted_valuerM   )r   STANDARD_TIME_SCALESr%   r   r)   warnsr   rO   r\   r"   rj   r-   rk   allr   r   serialize_methodvalue)r]   rE   rF   rj   r^   tmabr    s           r1    test_io_time_write_fits_standardr      s    	aVh1233A* 	
 	
VaV"8WgCHHH	
 
 
#+ ,.CDE
 
 
#+ 3ZAcF+%H 
2
 
 
 9 9 	
48889 9 9 9 9 9 9 9 9 9 9 9 9 9 9 
H
 
 
 L L hvdKK	L L L L L L L L L L L L L L L * / / 	/ 	/B:D bh	22222 d8>QtW]2222 d8?d**** d8$$(88888 tH$',,......!	/$ & + +"T(F+++++ 4AdG#((****** * F F 	F 	FB:D4EAdGL)&11	F GGHVtG444			(6		2	2B* 5 5 	5 	5B:D!"T(DI66666tH$-22444444		55 5s$   C  CC&DDDc                 "    |ddgddgg          }t          j        ddgddggd	d
t          dddd                    |d<   t          j        ddgd
          |d<   ddg|d<   | dz  }t          j        t
          d          5  |                    |dd           ddd           n# 1 swxY w Y   t          j        t
          d           5  |                    |dd!          }ddd           n# 1 swxY w Y   d"D ]}|d#z   }t          ||         t           j                  sJ ||         j	        ||         j	        k    sJ ||         j
        d$k    sJ ||         j        ||         j        k    sJ ||         ||         k                                    sJ d%D ]E}t          ||         t                    sJ ||         ||         k                                    sJ Fd"D ]}|d#z   }d&||         j        j        d<   |                    |dd           |                    |d'          }d"D ]T}|d#z   }t          ||         t           j                  rJ ||         ||         j        k                                    sJ UdS )(a  
    Test that table with a Time mixin with scale local can also be written
    by io.fits. Like ``test_io_time_write_fits_standard`` above, but avoiding
    ``cxcsec`` format, which requires an epoch and thus cannot be used for a
    local time scale.
    r   rT   rb   rc   iQ  iR  iS  iT  mjdlocalrf   rg   rh   r   rW   ri   a_localrl   rm   rn   b_localro   rp   rq   rX   z/Time Column "b_local" has no specified locationrr   rt   TrZ   Nz9Time column reference position "TRPOSn" is not specified.ru   rw   _localrx   ry   r|   rM   )r   r%   r   r)   r~   r   rO   r\   r"   rj   r-   rk   r   r   r   r   r   )r]   rE   rF   r^   r   r   r    s          r1   test_io_time_write_fits_localr      s    	aVh1233A9
%(x'DDD	  AiL 9	(*?@  AiL 3ZAcF+%H 
"S
 
 
 9 9 	
48889 9 9 9 9 9 9 9 9 9 9 9 9 9 9
 
I
 
 
 L L hvdKK	L L L L L L L L L L L L L L L  + +H} "T(DI..... $x~4.... $x$&&&& $x AdG$44444 4AdG#((******% + +"T(F+++++ 4AdG#((******  B BH}0A$%f--GGHVtG444			(6		2	2B 1 1H}bh	222224AdGM)..000000	1 1s$   B++B/2B/C66C:=C:c                    t          |           }|j                            t          t          j        f          }|st          j        d           t                      }t          j	        t                    5 }|                    |d           ddd           n# 1 swxY w Y   dt          |j                  v sJ dS )zf
    Test that table with mixin columns (excluding Quantity) cannot be written by
    io.votable.
    zno unsupported column typesrY   rM   Nz'cannot write table with mixin column(s))r   columnsnot_isinstancer   r#   r$   r)   skipr   r*   
ValueErrorrO   strr   )r0   rF   unsupported_colsrQ   errs        r1   test_votable_mixin_write_failr   .  s    
 	zA y//QZ0HII 31222
**C	z	"	" 'c	I&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' '4CIFFFFFFs   8BB #B c                 6   |                                  }|                     g d          |d<   |                     g d          |d<   t          j                    D ]
\  }}|||<   |                      |          }g d|d<   t          j                    D ],\  }}|||         j        _        |dz   ||         j        _        -dD ]}t          ||d|          }|d	         }|d
         }t          j                    D ]p\  }}|dz   }	|dz   }
t          ||	||                    t          ||
||                    ||	         j        j        |k    sJ ||
         j        j        |dz   k    sJ qdD ]^}t          j	        t                    5 }t          ||d|          }ddd           n# 1 swxY w Y   dt          |j                  v sJ _t          j	        t                    5 }t          ||ddg          }ddd           n# 1 swxY w Y   dt          |j                  v sJ t          j        t          d          5  t          ||dg          }ddd           n# 1 swxY w Y   t!          j        |d         |d         k              sJ dS )zq
    Join tables with mixin cols.  Use column "i" as proxy for what the
    result should be for each mixin.
    )r   r?   r?   rq   r   r   r   rT   rd   r>   )r?   rq   r   d2)innerleft)keys	join_typei_1i_2_1_2)outerrightNzjoin requires masking columnskycoord)r   z(one or more key columns are not sortablezFIn merged column 'quantity' the 'description' attribute does not matchrr   quantitya_1)r   r   r   itemsr   r!   r   assert_table_name_col_equalr)   r*   NotImplementedErrorr   r   	TypeErrorr~   r   npr   )rE   t1r    colt2r   t12idx1idx2name1name2excs               r1   	test_joinr   A  s   
 
				B  !5!5!566BsG  ..BsG%''  	c4			2		B"""BsG%'' / /	c$(4!$(3J4!!& 
= 
=	2ry9995z5z#)++ 	= 	=ID#4KE4KE'UCI>>>'UCI>>>u:?.$6666u:?.$*<<<<<	= ( @ @	].// 	>3r2C9===C	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>-SY?????	y	!	! 3S2rj 12223 3 3 3 3 3 3 3 3 3 3 3 3 3 35SYGGGG 
V
 
 
 . . 2r---	. . . . . . . . . . . . . . .
 6#e*3'(((((((s6   F,,F0	3F0	)H

HHI((I,/I,c           	         |                                  }|                     g d          |d<   t          j                    D ]0\  }}|||<   |||         j        _        ddi||         j        _        1dD ]{}dD ]t}|                      |          }|rm|dd         }|d	k    r]t          j        t                    5 }t          ||g|
          }ddd           n# 1 swxY w Y   dt          |j                  v sJ t          ||g|
          }|d         }	|d         }
t          j                    D ]\  }}|dz   }|dz   }t          ||||	                    t          ||||
                    dD ]v}t          ||         j        |          t          ||         j        |          k    sJ t          ||         j        |          t          ||         j        |          k    sJ wv}dS )zs
    Hstack tables with mixin cols.  Use column "i" as proxy for what the
    result should be for each mixin.
    r   r>   r   r   )r   r   )TFNr   )r   zhstack requires masking columnr   r   r   r   )r!   r.   )r   r   r   r   r   r!   r.   r)   r*   r   r   r   r   r   getattr)rE   r   r    r   r   chopr   r   r   r   r   r   r   attrs                 r1   test_hstackr   q  s   
 
				B  ..BsG%'' & &	c4$(4!!1X4'  	! 	 	D""2&&B W''':;; Ds$b"XCCCD D D D D D D D D D D D D D D;s39~~MMMM"bY777Cu:Du:D'-//  	ctt+CD	BBB+CD	BBB3  D"2d8=$777E
< <     #2d8=$777E
< <     		 s   =CC!$C!c                    t          |t          j                  rVt          j        | |         j        |j        k              sJ t          j        | |         j        |j        k              sJ dS t          |t          j                  r,t          j        t          | |         |                    sJ dS t          |t          j
                  r:t          |           t          u r t          j        | |         |k              sJ dS dS t          |t          j                  r,t          j        | |         j        |j        k              sJ dS t          j        | |         |k              sJ dS )zQ
    Assert all(t[name] == col), with special handling for known mixin cols.
    N)r"   r   r   r   r   radecr'   r
   r#   r$   r6   r   r   r   data)rF   r    r   s      r1   r   r     sX    #{+,, &vagjCF*+++++vagkSW,-------	CE	F	F &v*1T7C889999999	C	$	$ &77f6!D'S.))))) ))	C3	4	4 &vaglch.///////vagn%%%%%%%r<   c                    d}| d         }d|j         _        d|j         _        d|j         _        ddi|j         _        t          |g          }ddgt          j        dd	g          t          dd          fD ]}||         }||         }t          |d||                    |D ]d}t          |d         j         |          t          |j         |          k    sJ t          |j         |          t          |j         |          k    sJ ed
S )zU
    Test that slicing / indexing table gives right values and col attrs inherit
    r    r,   dtyper-   r!   r.   r   {0}r   r   r   rd   r   rT   N)r   r    r-   r!   r.   r   r   arrayslicer   r   )r0   attrsr   rF   itemr   m2r   s           r1   test_get_itemsr     s    GE3AAFKAFMAF(AFKsAQ1a&))5A;;7 C CtWtW#BQtW555 	C 	CD2c7<..'!&$2G2GGGGG27D))WQVT-B-BBBBBB	C	C Cr<   c                 P   d }d }d}dD ]}| |         }||j         _        d|j         _        d|j         _        ddi|j         _        t
          j        t
          j        ||fD ]} ||          }|D ]}|d	k    sYt          |j         j        d
d          s>|j         j        j        	                    d          s|t
          j        t
          j        fv rt          |j         |          }	n|j         j        
                    d          }	t          |j         |          |	k    sJ dS )z
    Test copy, pickle, and init from class roundtrip preserve info.  This
    tests not only the mixin classes but a regular column as well.
    c                 N    t          j        t          j        |                     S r4   )pickleloadsdumpsrq   s    r1   pickle_roundtripz>test_info_preserved_pickle_copy_init.<locals>.pickle_roundtrip  s    |FLOO,,,r<   c                 ,    |                      |           S r4   )	__class__r   s    r1   init_from_classz=test_info_preserved_pickle_copy_init.<locals>.init_from_class  s    {{1~~r<   r   )r>   r   r   r   r   r   r   isnativeTvoid=N)r   r    r-   r!   r.   copydeepcopyr   r   
startswithnewbyteorder)
r0   r   r   r   colnamer   funcr   r   originals
             r1   $test_info_preserved_pickle_copy_initr     sY   - - -   GE : :w AhY/?Q 	: 	:DaB : : GOOqv|Z>> $v|(33F;; $ 	4=999&qvt44HH  !v|88==Hrw--99999:	:: :r<   c                    t          | t                    r=| j        j                                        }|j        j                                        }n2| j                                        }|j                                        }d t          |                                |                                          D             }|rt          |          rJ dS t          |          sJ dS )zCheck whether data attributes in col1 and col2 share memory.

    If copy=True, this should not be the case for any, while
    if copy=False, all should share memory.
    c                     g | ];\  }}t          |t          j                  |j        &t          j        ||          <S  )r"   r   ndarrayshapemay_share_memory).0v1v2s      r1   
<listcomp>z&check_share_memory.<locals>.<listcomp>  sW       Rb"*%% +-(
B##  r<   N)	r"   r   r   r   _represent_as_dictziprD   anyr   )r{   col2r   map1map2shareds         r1   check_share_memoryr     s     $!! . y~0022y~0022y++--y++-- DKKMM4;;==99  F
  v;;6{{r<   r   TFc                    d}| d         }|j         j        J t          |gdg|          }|j         j        J t          ||d         |           ||d<   |j         j        J t          ||d         d           d|j         _        d	|j         _        d
|j         _        ddi|j         _        t          |g|          }|j        dgk    sJ t          ||d         |           t          |gdg|          }|j         j        dk    sJ |j        dgk    sJ t          ||d         |           ||d<   t          ||d         d           d|j         _        |                    |g|           t          ||d         |           dD ]X}t          |||           |D ]B}|dk    r:t          |d         j         |          t          ||         j         |          k    sJ CY|d         }t          |          t          |          u rd|j        v r|d         |d<   t          |d|d                    t          ||d         d           |D ]B}|dk    r:t          |d         j         |          t          |d         j         |          k    sJ Ct          |dd         gdg|          }t          ||d         |           t          |          t          |          u rpd|j        v ri|d         |d<   t          |d|d                    |D ]F}|dk    r:t          |d         j         |          t          |d         j         |          k    sJ CdS dS dS )z
    Test that adding a column preserves values and attributes.
    For copy=True, the data should be independent;
    for copy=False, the data should be shared, but the instance independent.
    r   r   Nr   rA   r   r   newTr   r   r   m1r   m3)r   r   r    r   r   srT   )r   r    r   r   r-   r!   r.   colnamesadd_columnsr   r   r6   __dict__)r0   r   r   r   rF   r    r   r   s           r1   test_add_columnr     s    GE3A6; 	s3%d+++A6;q!C&t,,,,AeH6;q!E(....AFKAFMAF(AFKsA:#q!C&t,,,,s4&t,,,A6;#:$q!D'---- AdGq!D'----AFKMM1#DM!!!q!D'---- R R#AtQ/// 	R 	RDv~~qw|T22gaglD6Q6QQQQQ	R 	
!AAww$q''f
22 1##AsAaD1111af40000 	Q 	QDv~~qw|T22gafk46P6PPPPP 	!A#xu4000Aq!C&t,,,,Aww$q''f
221##AsAaD111 	Q 	QDv~~qw|T22gafk46P6PPPPP 22	Q 	Qr<   c                      t          t                    } t          t                    }t          j        t                    5  t          | |g           ddd           dS # 1 swxY w Y   dS )z(
    Vstack tables with mixin cols.
    N)r   r   r)   r*   r   r   )r   r   s     r1   test_vstackr   B  s     

		B	
		B	*	+	+  Bx                 s   A!!A%(A%c                     t          |           }|                                }d|d         j        _        g d}t	          |d         t
          j        t          t          j	        t          j
        t          j        f          r|                    d|d                    |j        D ]i}||         }t	          |t          j                  rt          |||         |                   sJ Ct!          j        |||         |         k              sJ j|d         j        j        dk    sJ dS t%          j        t(                    5 }|                    d|d                    ddd           n# 1 swxY w Y   dt+          |j                  v sJ dS )zT
    Test inserting a row, which works for Column, Quantity, Time and SkyCoord.
    r   r   )r   r   r   rT   rd   r   r   NzUnable to insert row)r   r   r   r!   r"   r#   r$   r   r   r%   r&   r   r   
insert_rowr   r	   r   r   r)   r*   r   r   r   )r0   rF   t0idxsr    r   r   s          r1   test_insert_rowr  L  s    	zA	
B!AcFKD	#VTY@TU  8 	
Q"J 	5 	5DD'C#{344 5%c2d8D>::::::vcRXd^3444444v{&#------]:&& 	##LLAbE"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#%SY777777s   E++E/2E/c                  6   t          dgt          j        z  g          } t          j        t
                    5 }|                     ddt          j        z  t          j        z  f           ddd           n# 1 swxY w Y   dt          |j	                  v sJ dS )z8
    Insert a row into a QTable with the wrong unit
    r   r   rT   Nz='m / s' (speed/velocity) and 'm' (length) are not convertible)
r   r#   r   r)   r*   r   r   r   r   r   )rF   r   s     r1   test_insert_row_bad_unitr  g  s     	ac	{A	z	"	" *c	QQS13()))* * * * * * * * * * * * * * *Jc	O O      s   2A66A:=A:c                     t          |           }|                                }| d         }t          |d          r|j        j        nd}|d         j        j        |k    sJ dS )z
    Test that converting to numpy array creates an object dtype and that
    each instance in the array has the expected type.
    r   r   ON)r   as_arrayhasattrr   kind)r0   rF   tar   
dtype_kinds        r1   test_convert_np_arrayr  s  sc    
 	zA	
B3A!(G!4!4=#Jc7=++++++r<   c                     dD ]} t           |          }t          |gdg          }dt          dd          t          dd          ft          j        ddg          t          j        ddg          ffD ]d\  }}|                                }||         |d         |<   | d	k    rt          j        |d         j        |         |j        |         k              sJ t          j        |d         j        |         |j        |         k              sJ t          j        |d         j        |         |d         j        |         k              sJ t          j        |d         |         ||         k              sJ t          j        |d         |         ||         k              sJ t          j        |d         |         |d         |         k              sJ fd
S )zx
    Test that assignment of an int, slice, and fancy index works.
    Along the way test that copying table works.
    )r   	arraywrapr   r@   )r   rT   r   rT   r   rd   r  N)r   r   r   r   r   r   r   r   )r    r   r   i0i1rF   s         r1   test_assignment_and_copyr    s   
 * 9 9tQCu%%%1a[[%1++&Xq!frxA//0
 	9 	9FB
 		A2AcF2J{""vafk"o;<<<<<vbgl2.!&*<=====vbgl2.!C&+b/ABBBBBBvafRjAbE122222vbgbkQrU233333vbgbkQsVBZ7888888	99 9r<   c                  p   t          t                    } | j        }|D ]}|| |         j        _        t          |           }|D ]}||         j        j        |k    sJ |dk    rwt          j        |d         | d         j        k              sJ t          j        |d         j	        | d         j	        u           sJ t          |d         |j                  sJ t          ||| |                    t          |           }|D ]1}||         j        j        |k    sJ t          ||| |                    2dS )zF
    Test that a table round trips from QTable => Table => QTable
    r   N)r   r   r   r   r!   r   r   r   r   r,   r"   r7   r   )r_   rA   r    rF   qt2s        r1   test_conversion_qtable_tabler    sU    

		BKE ) )$(4!!b		A ; ;w|'4////:6!J-2j>+??@@@@@6!J-,:0CCDDDDDa
mQ];;;;;;'4D::::
**C 9 94y~)T1111#Cr$x88889 9r<   c                      t                      } ddg| d<   d| d<   t          j        | d         ddgk              sJ t          j        | d         ddgk              sJ dS )z?
    Test for mixin-related regression described in #3321.
    xyr   r?   N)r   r   r   rF   s    r1   test_setitem_as_column_namer    so     	A3ZAcFAcF6!C&S#J&'''''6!C&S#J&'''''''r<   c                  |    t          ddgt          j        z  g          } |                                 g dk    sJ dS )zI
    Test that table representation of quantities does not have unit
    r   rT   )rz   z m  z----z 1.0z 2.0N)r   r#   r   pformatr  s    r1   test_quantity_representationr    sU     	A~A99;;         r<   c                     t          j        dgdgdgt          j                  } t	          | g          }|                                g dk    sJ t          j        dgdgdgd          } t	          | g          }|                                g dk    sJ t          j        dgt          j        z  dgt          j        z  dgt          j        z            } t	          | g          }|                                g d	k    sJ t          j	        dgt          j        z  dgt          j        z            } t	          | g          }|                                g d
k    sJ t          j
        dgt          j        z  t          j        z  dgt          j        z  t          j        z  dgt          j        z  t          j        z            } t	          | g          }|                                g dk    sJ dS )z>
    Test that Representations are represented correctly.
    r   r   rW   )    col0    ------------(0., 1., 0.)r   )r  z     m      r  r  
      )     col0     z deg, deg, pc --------------z(10., 20., 1.))z
   col0   z
   deg    z
----------z
(10., 20.)rT   )z           col0           zmas / yr, mas / yr, km / sz--------------------------z            (10., 2., 10.)N)r   CartesianRepresentationr#   oner   r  SphericalRepresentationdegpcUnitSphericalRepresentationSphericalCosLatDifferentialmasyrkmr   rq   rF   s     r1   "test_representation_representationr/    s   
 	+QC!qcFFFAqc

A99;;        	+QC!qcDDDAqc

A99;;        	+RD15L2$,ad
SSAqc

A99;;        	/qurdQUlKKAqc

A99;;        	/	quqtaS15[14/"qs1B	 	A 	qc

A99;;         r<   c                     t          j        dgdgdgd          } t          | g          }|                                g dk    sJ t          j        dgdgdgdd          } t          | g          }|                                g dk    sJ d	|d
         _        |                                g dk    sJ d|d
         _        |                                g dk    sJ dS )z
    Test that skycoord representation works, both in the way that the
    values are output and in changing the frame representation.
    r   r   	cartesian)representation_type)r"  zNone,None,Noner#  z   0.0,1.0,0.0r   )r,   r2  )z    col0   z   m,m,m   z-----------z0.0,1.0,0.0unitsphericalrz   )  col0  zdeg,deg --------z90.0,0.0cylindrical)r  z  m,deg,m   r  z1.0,90.0,0.0N)r   r   r   r  r2  r.  s     r1   test_skycoord_representationr7    s>    	aS1#sLLLAqc

A99;;        	aS1#s+VVVAqc

A99;;        %4AfI!99;;        %2AfI!99;;         r<   as_ndarray_mixinc                    t          j        g dd          }t          j        g dddg          }t           j                            g ddd	g
          }t          j        dd                              dd          }| rp|                    t                    }|                    t                    }|                    t                    }|                    t                    }t          }nt          }t          |gdg
          }||d<   ||d<   ||d<   t          |d         |          sJ |d         d         d         |d         d         k    sJ |d         d         d         |d         d         k    sJ |d         d         d         |d         d         k    sJ |d         d         d         |d         d         k    sJ t          |d         |          sJ |d         d         d         |d         d         k    sJ |d         d         d         |d         d         k    sJ |d         d         d         |d         d         k    sJ |d         d         d         |d         d         k    sJ t          |d         |          sJ |d         d         d         |d         d         k    sJ |d         d         d	         |d         d	         k    sJ |d         d         d         |d         d         k    sJ |d         d         d	         |d         d	         k    sJ t          |d         |          sJ |d         d         d         |d         d         k    sJ |d         d         d         |d         d         k    sJ |d         d         d         |d         d         k    sJ |d         d         d         |d         d         k    sJ |                    d          g dk    sJ dS )a'  
    Test directly adding various forms of structured ndarray columns to a table.
    Adding as NdarrayMixin is expected to be somewhat unusual after #12644
    (which provides full support for structured array Column's). This test shows
    that the end behavior is the same in both cases.
    ))r   r   )rT   r?   )rd   rq   )rU   r   z<i4,|U1)r   ))r   aa)r!  bb)   cc)(   dd)r  i4)r  U2))g      Y@raa)g      i@rbb)g     r@rcc)g      y@rddrxryr@      i8rU   rT   r   r?   rq   r   r   r   r  r  T)
show_dtype)z4  a [f0, f1]     b [x, y]      c [rx, ry]      d    z4(int32, str1) (int32, str2) (float64, str3) int64[2]z4------------- ------------- --------------- --------z4     (1, 'a')    (10, 'aa')   (100., 'raa')   0 .. 1z4     (2, 'b')    (20, 'bb')   (200., 'rbb')   2 .. 3z4     (3, 'c')    (30, 'cc')   (300., 'rcc')   4 .. 5z4     (4, 'd')    (40, 'dd')   (400., 'rdd')   6 .. 7N)r   r   recfromrecordsarangereshapeviewr   r   r   r"   r  )r8  r   r?   rq   r   	class_exprF   s          r1   test_ndarray_mixinrQ  (  s    	999PPPA
888K(	 	 	A 	HHHTl 	 	 	A 		!4   ((A..A FF<  FF<  FF<  FF<   			 	qc#AAcFAcFAcFafi(((((S6!9Q<1Q47""""S6!9Q<1Q47""""Q49Q<1Q47""""Q49Q<1Q47""""afi(((((S6!9S>QqT#Y&&&&S6!9S>QqT#Y&&&&Q49S>QqT#Y&&&&Q49S>QqT#Y&&&&afi(((((S6!9T?ad4j((((S6!9T?ad4j((((Q49T?ad4j((((Q49T?ad4j((((afi(((((S6!9Q<1Q47""""S6!9Q<1Q47""""Q49Q<1Q47""""Q49Q<1Q47""""999%% * * *      r<   c                  X   t          ddgt          j        z  g          } d| d         j        _        |                                 g dk    sJ d| d         j        _        |                                 g dk    sJ d| d         j        _        |                                 g d	k    sJ d
S )z
    The QuantityInfo info class for Quantity implements a
    possible_string_format_functions() method that overrides the
    standard pprint._possible_string_format_functions() function.
    Test this.
    r   rT   z%.3frz   )z col0z  m  z-----z1.000z2.000z	hi {:.3f})r4  z   m    r5  zhi 1.000zhi 2.000z.4f)z col0 z  m   z------z1.0000z2.0000N)r   r#   r   r   r-   r  r  s    r1   %test_possible_string_format_functionsrS  u  s     	A~A"AfIN99;;        (AfIN99;;        "AfIN99;;         r<   c                 .   t          |           }|                                }|                    dd           |j        g dk    sJ t	          |d         t
          j                  r2t          j        |d         j	        |d         j	        k              sJ dS t	          |d         t          j                  rbt          j        |d         j        |d         j        k              sJ t          j        |d         j        |d         j        k              sJ dS t	          |d         t          j                  r2t          j        t          |d         |d                             sJ dS t          j        |d         |d         k              sJ dS )z 
    Rename a mixin column.
    r   mm)r>   r   r?   rU  N)r   r   rename_columnr   r"   r   r   r   r   r   r   r   r   r   r'   r
   )r0   rF   tcs      r1   test_rename_mixin_columnsrX    sp    	zA	
BOOC:.......!D'=566 *vaglbgl23333333	AdG[1	2	2 *vagjBsGJ./////vagkRW[01111111	AdG[I	J	J *v*1T7BsG<<=======vagC()))))))r<   c                      t          dddgid          } d| d         _        d| d         j        d<   t          j        |            dS )zv
    If the unit is invalid for a column that gets serialized this would
    cause an exception.  Fixed in #7481.
    r   r   rT   T)maskedznot a valid unitN)r   r,   maskr   r   r  s    r1   )test_represent_mixins_as_columns_unit_fixr\    sO    
 	sQFmD)))A$AcFKAcFKN)!,,,,,r<   c                  0   t          dddgt          j        z  i          } d| d         j        _        d| d         j        _        t          j        |           }d|j        d         d         vsJ |d         j        dk    sJ |d         j        dk    sJ dS )	z
    If the mixin defines a primary data column, that should get the
    description, format, etc., so no __info__ should be needed.
    r   r   rT   parrotz7.2f__info____serialized_columns__N)	r   r#   r   r   r!   r-   r   r   r.   )rF   tsers     r1   )test_primary_data_column_gets_descriptionrb    s    
 	aVac\"##A&AcFKAcFK033DTY'?@EEEEE9v%%%%9 H,,,,,,r<   c                  F   t          dgdgdd           } t          | g          }t                      }|                    |dd           |                    d           t          j        |                                d	          }t          |d
         |           sJ d S )Nr   rT   r'  )r,   galcen_v_sunz
ascii.ecsvTrZ   r   rM   rz   )r   r   r   rO   seekr\   r	   )scrF   r   r   s       r1   test_skycoord_with_velocityrg    s    	1#sT	:	:	:BrdA

AGGAldG333FF1III	AFFHH\	2	2	2B"V*b)))))))r<   	table_clsc                 F   ddgt           j        z  }d|j        vsJ  | |gdg|          }d|j        vsJ  | |g|          }d|j        vsJ  | d|i|          }d|j        vsJ ||d<   d|j        vsJ t          ddgddgd	
          }||d<   d|j        vsJ dS )zIf a mixin input to a table has no info, it should stay that way.

    This since having 'info' slows down slicing, etc.
    See gh-11066.
    r   rT   r   qr   r   q2rd   r'  rW   rf  N)r#   r   r   r   )rh  r   rj  rF   rf  s        r1   #test_ensure_input_info_is_unchangedrl    s    
AA####	1#cU...A####	1#D!!!A####	3(&&&A####AdG####	1a&1a&u	-	-	-BAdG$$$$$$r<   c                      G d dt                     } t                      } | g d          |d<   t                      }d}t          j        t
          |          5  t          |           ddd           dS # 1 swxY w Y   dS )zjMake a mixin column class that does not trigger the machinery to generate
    a pure column representationc                   "    e Zd Z e            ZdS )+test_bad_info_class.<locals>.MyArrayWrapperN)__name__
__module____qualname__r   r   r   r<   r1   MyArrayWrapperro    s          r<   rs  )r   r   rT   r   zSfailed to represent column 'tm' \(MyArrayWrapper\) as one or more Column subclassesrr   N)r   r   r   r)   r*   r   r   )rs  rF   rQ   rs   s       r1   test_bad_info_classrt    s    ! ! ! ! ! ! ! ! 	AnYYY''AdG
**C	 
 
y	.	.	. ' '#A&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 's   A::A>A>)Or   r   ior   numpyr   r)   astropyr   r   r   r#   astropy.coordinatesr   r    astropy.coordinates.tests.helperr	   -astropy.coordinates.tests.test_representationr
   astropy.tabler   r   r   r   r   r   r   r   r   astropy.table.columnr   astropy.table.serializer   astropy.table.table_helpersr   astropy.utils.data_infor   astropy.utils.exceptionsr   astropy.utils.metadatar   conftestr   r2   r;   rH   rR   r`   markremote_dataparametrizer   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r/  r7  rQ  rS  rX  r\  rb  rg  rl  rt  r   r<   r1   <module>r     s                % % % % % % % %       7 7 7 7 7 7 7 7 ; ; ; ; ; ; N N N N N N
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 , + + + + + ? ? ? ? ? ? 4 4 4 4 4 4 3 3 3 3 3 3 7 7 7 7 7 7 7 7 7 7 7 7            ' ' 'T$ $ $4 4 4 / / /     " 88P5 P5 98 P5f 88G1 G1 98G1TG G G&-) -) -)`% % %P& & &$C C C(!: !: !:H  8 $//?Q ?Q 0/?QD  8 8 86	 	 		, 	, 	,9 9 929 9 92( ( (  1 1 1h' ' 'T +dE];;I I <;IX! ! !H* * *&- - -- - -* * * $//ufo66% % 76 0/%*' ' ' ' 'r<   