
    HR-e                         d dl m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mZ d Zd Zd	 Zd
 Zd Zd Zd Zd Zd ZdZ ej        eej                  Zd Zd ZdS )    )StringION)ascii)QTable   )assert_almost_equalassert_equalc                 n    t          |                                 |                                           d S )N)r   
splitlines)arg1arg2s     ?lib/python3.11/site-packages/astropy/io/ascii/tests/test_rst.pyassert_equal_splitlinesr      s,    ""DOO$5$566666    c                  H   d} t          j        t           j                  }|                    |           }t	          |j        ddg           t          |d         d         d           t	          |d         d         d           t	          |d         d         d	           d
S )zNormal SimpleRST Table
# comment (with blank line above)
======= =========
   Col1      Col2
======= =========
   1.2    "hello"
   2.4  's worlds
======= =========
ReaderCol1Col2r   r   333333@z"hello"	's worldsNr   
get_readerRSTreadr   colnamesr   tablereaderdats      r   test_read_normalr!      s    E UY///F
++e

C/000Aq	3'''QI&&&QK(((((r   c                      d} t          j        t           j        d          }|                    |           }t	          |j        ddg           t          |d         d         d           d	S )
1Normal SimpleRST Table with provided column namesr   )name1name2)r   namesr$   r%   r   r   r   Nr   r   s      r   test_read_normal_namesr'   %   si    E UY6HIIIF
++e

C1222Aq	3'''''r   c                     d} t          j        t           j        dd          }|                    |           }t	          |j        ddg           t          |d         d         d	           t	          |d         d         d
           dS )r#   z
# comment (with blank line above)
=======  ========== ======
   Col1     Col2      Col3
=======  ========== ======
   1.2     "hello"       3
   2.4    's worlds      7
=======  ========== ======
)r$   r%   name3)r$   r)   )r   r&   include_namesr$   r)   r   r   r      Nr   r   s      r   test_read_normal_names_includer,   6   s    E y)(  F
 ++e

C1222Aq	3'''QAr   c                      d} t          j        t           j        d          }|                    |           }t	          |j        dg           t	          |d         d         d           dS )	z4Nice, typical SimpleRST table with col name excludedzo
======= ==========
  Col1     Col2
======= ==========
  1.2     "hello"
  2.4    's worlds
======= ==========
)r   )r   exclude_namesr   r   r   r   Nr   r   r   r   r   r   r   s      r   test_read_normal_excluder0   L   se    E UYiHHHF
++e

Cx(((QK(((((r   c                      d} t          j        t           j                  }|                    |           }t	          |d         d         d           t	          |d         d         d           dS )	3The right hand column should be allowed to overflowz
# comment (with blank line above)
===== ===== ====
 Col1  Col2 Col3
===== ===== ====
 1.2    2    Hello
 2.4     4   Worlds
===== ===== ====
r   r      Hellor   WorldsN)r   r   r   r   r   r   s      r    test_read_unbounded_right_columnr6   \   sg    E UY///F
++e

CQG$$$QH%%%%%r   c                      d} t          j        t           j                  }|                    |           }t	          |j        d         d           dS )r2   z
# comment (with blank line above)
===== ===== ====
 Col1  Col2 Col3Long
===== ===== ====
 1.2    2    Hello
 2.4     4   Worlds
===== ===== ====
r   Col3LongNr/   r   s      r   'test_read_unbounded_right_column_headerr:   m   sN    E UY///F
++e

Cb!:.....r   c                     d} t          j        t           j                  }|                    |           }t	          |j        g d           t	          |d         d         d           t	          |d         d         d           dS )	z9We should be able to read right indented tables correctlyz
# comment (with blank line above)
   ==== ==== ====
   Col1 Col2 Col3
   ==== ==== ====
    3    3.4  foo
    1    4.5  bar
   ==== ==== ====
r   r   r   Col3r   r3   foor   Nr/   r   s      r   test_read_right_indented_tabler?   }   s    E UY///F
++e

C777888QE"""QAr   c                  :   d} t          |           dk    sJ t          j        t          j                  }|                    |           }t          |j        g d           t          |d         d         d           t          |d         d         d           d	S )
z=Trailing spaces in the row definition column shouldn't matterz
# comment (with blank line above)
   ==== ==== ====    
   Col1 Col2 Col3
   ==== ==== ====  
    3    3.4  foo
    1    4.5  bar
   ==== ==== ====  
   r   r<   r   r3   r>   r   N)lenr   r   r   r   r   r   r   s      r   &test_trailing_spaces_in_row_definitionrC      s    	  
 u::UY///F
++e

C777888QE"""QAr   z====== =========== ============ ===========
  Col1    Col2        Col3        Col4
====== =========== ============ ===========
  1.2    "hello"      1           a
  2.4   's worlds          2           2
====== =========== ============ ===========
r   c                      t                      } t          j        t          | t          j                   t          |                                 d           dS )z)Write a table as a normal SimpleRST Table)Writerz==== ========= ==== ====
Col1      Col2 Col3 Col4
==== ========= ==== ====
 1.2   "hello"    1    a
 2.4 's worlds    2    2
==== ========= ==== ====
N)r   r   writer    r   r   getvalue)outs    r   test_write_normalrI      sP    
**C	KS++++	
 
 
 
 
r   c                  
   g d} t          j        | dg d          }|d         j        t          j        k    sJ |d         j        t          j        k    sJ |d         j        t          j        k    sJ |d         j        t          j	        k    sJ |d         j        t          j
        k    sJ t                      }|                    |dg d           |                                                                | k    sJ dS )	z-Round-trip a table with header_rows specified)======= ======== ====z   wave response intsz     nm       ct     zfloat64  float32 int8rK   z  350.0      1.0    1z  950.0      2.0    2rK   z	ascii.rst)nameunitdtype)formatheader_rowswaveresponseintsN)r   r   rM   unmctrN   npfloat64float32int8r   rF   rG   r
   )linestblrH   s      r   test_rst_with_header_rowsr]      s   	 	 	E +eK=V=V=V
W
W
WCv;qt####z?14''''v;
****z? BJ....v;''''
**CIIc+3L3L3LIMMM<<>>$$&&%//////r   )ior   numpyrW   astropy.unitsunitsrT   
astropy.ior   astropy.tabler   commonr   r   r   r!   r'   r,   r0   r6   r:   r?   rC   r   r   r   r    rI   r]    r   r   <module>rf      sC                                     5 5 5 5 5 5 5 57 7 7) ) )&( ( ("  ,) ) ) & & &"/ / /   $  .	 ejuy)))  "0 0 0 0 0r   