
    h                     J   d dl m 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
  ej                  d       d Zej                  d        Z G d d	      Z G d
 d      Z G d d      Z G d d      Z G d d      Z G d d      Z G d d      Z G d d      Z G d d      Zy)    )datetime)dedentN)	DataFrameSeriesjinja2c                 4    t        |       j                         S )zDedent without new line in the beginning.

    Built-in textwrap.dedent would keep new line character in the beginning
    of multi-line string starting from the new line.
    This version drops the leading new line character.
    )r   lstrip)strings    JD:\jyotish\venv\Lib\site-packages\pandas/tests/io/formats/test_to_latex.py_dedentr      s     &>  ""    c                  &    t        ddgddgd      S )z>Short dataframe for testing table/tabular/longtable LaTeX env.      b1b2abr    r   r   df_shortr      s     Aq6t566r   c                       e Zd Zd Zd Zd Zd Zd Zej                  j                  dddd	d
gdh dd
d	dg      d        Zd Zd Zd Zd Zd Zd Zd Zy)TestToLatexc                    t        j                  d      5 }|j                  |       t        |d      5 }|j                         |j	                         k(  sJ 	 d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Ntest.texutf-8encoding)tmensure_cleanto_latexopenread)selffloat_framepathfs       r   test_to_latex_to_filez!TestToLatex.test_to_latex_to_file!   sd    __Z(D  &dW-"++-999 . )(-- )(s"   A7$A+A7+A4	0A77B c                 $   t        dgg      }t        j                  d      5 }|j                  |d       t	        |d      5 }|j                         |j                         k(  sJ 	 d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY wNu
   außgangenr   r   r   r   r    r!   r"   r#   r$   r%   dfr'   r(   s       r   (test_to_latex_to_file_utf8_with_encodingz4TestToLatex.test_to_latex_to_file_utf8_with_encoding'   ss    ()*__Z(DKKwK/dW-{{}000 . )(-- )(s#   !B$A:)B:B	?BBc                     t        dgg      }t        j                  d      5 }|j                  |       t	        |d      5 }|j                         |j                         k(  sJ 	 d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY wr+   r,   r-   s       r   +test_to_latex_to_file_utf8_without_encodingz7TestToLatex.test_to_latex_to_file_utf8_without_encoding/   so    ()*__Z(DKKdW-{{}000 . )(-- )(s#   B$A8'B8B	=BBc                 l    t        ddgddgd      }|j                         }t        d      }||k(  sJ y )Nr   r   r   r   r   
            \begin{tabular}{lrl}
            \toprule
             & a & b \\
            \midrule
            0 & 1 & b1 \\
            1 & 2 & b2 \\
            \bottomrule
            \end{tabular}
            r   r"   r   r%   r.   resultexpecteds       r    test_to_latex_tabular_with_indexz,TestToLatex.test_to_latex_tabular_with_index7   sC    aV4,78	
 !!!r   c                 p    t        ddgddgd      }|j                  d      }t        d      }||k(  sJ y )	Nr   r   r   r   r   Findexz
            \begin{tabular}{rl}
            \toprule
            a & b \\
            \midrule
            1 & b1 \\
            2 & b2 \\
            \bottomrule
            \end{tabular}
            r4   r5   s       r   #test_to_latex_tabular_without_indexz/TestToLatex.test_to_latex_tabular_without_indexH   sH    aV4,785)	
 !!!r   bad_column_format   g333333?lr)r@   c>   rA   r?   r@   r   c                     t        ddgddgd      }d}t        j                  t        |      5  |j	                  |       d d d        y # 1 sw Y   y xY w)	Nr   r   r   r   r   z&`column_format` must be str or unicodematchcolumn_formatr   pytestraises
ValueErrorr"   )r%   r=   r.   msgs       r   test_to_latex_bad_column_formatz+TestToLatex.test_to_latex_bad_column_formatY   sI    
 aV4,787]]:S1KK&7K8 211s   AAc                 (    |j                  d       y )NlcrrE   r"   )r%   r&   s     r   &test_to_latex_column_format_just_worksz2TestToLatex.test_to_latex_column_format_just_worksc   s    51r   c                 p    t        ddgddgd      }|j                  d      }t        d      }||k(  sJ y )	Nr   r   r   r   r   rN   rE   z
            \begin{tabular}{lcr}
            \toprule
             & a & b \\
            \midrule
            0 & 1 & b1 \\
            1 & 2 & b2 \\
            \bottomrule
            \end{tabular}
            r4   r5   s       r   test_to_latex_column_formatz'TestToLatex.test_to_latex_column_formatg   sH    aV4,7851	
 !!!r   c                 z    t        ddg      }|j                  dj                        }t        d      }||k(  sJ y )Ng     @@testz{:,.0f}float_formatz
            \begin{tabular}{ll}
            \toprule
             & 0 \\
            \midrule
            0 & 1,000 \\
            1 & test \\
            \bottomrule
            \end{tabular}
            )r   r"   formatr   )r%   serr6   r7   s       r   %test_to_latex_float_format_object_colz1TestToLatex.test_to_latex_float_format_object_colx   sF    ff%&9+;+;<	
 !!!r   c                 \    t               }|j                         }t        d      }||k(  sJ y )Nz
            \begin{tabular}{l}
            \toprule
            \midrule
            \bottomrule
            \end{tabular}
            r4   r5   s       r   test_to_latex_empty_tabularz'TestToLatex.test_to_latex_empty_tabular   s3    [
 !!!r   c                 b    t        g d      }|j                         }t        d      }||k(  sJ y )Nr   r   rA   z
            \begin{tabular}{ll}
            \toprule
             & 0 \\
            \midrule
            0 & a \\
            1 & b \\
            2 & c \\
            \bottomrule
            \end{tabular}
            )r   r"   r   )r%   sr6   r7   s       r   test_to_latex_seriesz TestToLatex.test_to_latex_series   s6    ?#

 !!!r   c                     t        dddgi      }d|j                  _        |j                  d      }t	        d      }||k(  sJ y )Nr   r   r   fooF)index_namesz
            \begin{tabular}{lr}
            \toprule
             & a \\
            \midrule
            0 & 1 \\
            1 & 2 \\
            \bottomrule
            \end{tabular}
            )r   r;   namer"   r   r5   s       r   test_to_latex_midrule_locationz*TestToLatex.test_to_latex_midrule_location   sN    aV}%/	
 !!!r   c                     t        ddgddgddgd      }d}t        j                  t        |	      5  |j	                  d d        d d d        y # 1 sw Y   y xY w)
NRaphael	Donatello   -   g(\f@g4f@)rc   ageheightznStarting with pandas version 3.0 all arguments of to_latex except for the argument 'buf' will be keyword-only.rC   )r   r    assert_produces_warningFutureWarningr"   )r%   r.   rK   s      r   "test_to_latex_pos_args_deprecationz.TestToLatex.test_to_latex_pos_args_deprecation   s_    "K0Bx!6*
8 	 ''SAKKd# BAAs   AAN)__name__
__module____qualname__r)   r/   r1   r8   r<   rH   markparametrizerL   rP   rR   rY   r[   r_   rd   rn   r   r   r   r   r       s}    :11"""" [[	
C#sZ#:NO9	92"""$""$"&$r   r   c                       e Zd Zd Zd Zd Zej                  j                  d e	dddgi      df e	ddgdd	gd
      df e	ddgdd	gddgd      dfg      d        Z
y)TestToLatexLongtablec                 `    t               }|j                  d      }t        d      }||k(  sJ y )NT	longtableaw  
            \begin{longtable}{l}
            \toprule
            \midrule
            \endfirsthead
            \toprule
            \midrule
            \endhead
            \midrule
            \multicolumn{0}{r}{Continued on next page} \\
            \midrule
            \endfoot
            \bottomrule
            \endlastfoot
            \end{longtable}
            r4   r5   s       r   test_to_latex_empty_longtablez2TestToLatexLongtable.test_to_latex_empty_longtable   s8    [t,
$ !!!r   c                 p    t        ddgddgd      }|j                  d      }t        d      }||k(  sJ y )	Nr   r   r   r   r   Trw   a  
            \begin{longtable}{lrl}
            \toprule
             & a & b \\
            \midrule
            \endfirsthead
            \toprule
             & a & b \\
            \midrule
            \endhead
            \midrule
            \multicolumn{3}{r}{Continued on next page} \\
            \midrule
            \endfoot
            \bottomrule
            \endlastfoot
            0 & 1 & b1 \\
            1 & 2 & b2 \\
            \end{longtable}
            r4   r5   s       r   "test_to_latex_longtable_with_indexz7TestToLatexLongtable.test_to_latex_longtable_with_index   sH    aV4,78t,
, !!!r   c                 r    t        ddgddgd      }|j                  dd      }t        d	      }||k(  sJ y )
Nr   r   r   r   r   FTr;   rx   a  
            \begin{longtable}{rl}
            \toprule
            a & b \\
            \midrule
            \endfirsthead
            \toprule
            a & b \\
            \midrule
            \endhead
            \midrule
            \multicolumn{2}{r}{Continued on next page} \\
            \midrule
            \endfoot
            \bottomrule
            \endlastfoot
            1 & b1 \\
            2 & b2 \\
            \end{longtable}
            r4   r5   s       r   %test_to_latex_longtable_without_indexz:TestToLatexLongtable.test_to_latex_longtable_without_index  sJ    aV4,785D9
, !!!r   zdf, expected_numberr   r   r         r   r>      r]   c                 >    |j                  dd      }d| d|v sJ y )NFTr}   z\multicolumn{}rO   )r%   r.   expected_numberr6   s       r   .test_to_latex_longtable_continued_on_next_pagezCTestToLatexLongtable.test_to_latex_longtable_continued_on_next_page  s.     5D9  14>>>r   N)ro   rp   rq   ry   r{   r~   rH   rr   rs   r   r   r   r   r   ru   ru      s    "."6"6 [[aV}%q)aV1a&12A6aV1a&1v>?C	
??r   ru   c                   |    e Zd Zd Zd Zd Zd Zej                  j                  ddgdfdd	d
g      d        Z
d Zy)TestToLatexHeaderc                 p    t        ddgddgd      }|j                  d      }t        d      }||k(  sJ y )	Nr   r   r   r   r   Fheaderz
            \begin{tabular}{lrl}
            \toprule
            \midrule
            0 & 1 & b1 \\
            1 & 2 & b2 \\
            \bottomrule
            \end{tabular}
            r4   r5   s       r   "test_to_latex_no_header_with_indexz4TestToLatexHeader.test_to_latex_no_header_with_index*  sH    aV4,78E*

 !!!r   c                 r    t        ddgddgd      }|j                  dd      }t        d      }||k(  sJ y )	Nr   r   r   r   r   F)r;   r   z
            \begin{tabular}{rl}
            \toprule
            \midrule
            1 & b1 \\
            2 & b2 \\
            \bottomrule
            \end{tabular}
            r4   r5   s       r   %test_to_latex_no_header_without_indexz7TestToLatexHeader.test_to_latex_no_header_without_index;  sJ    aV4,7857

 !!!r   c                 t    t        ddgddgd      }|j                  ddg      }t        d	      }||k(  sJ y )
Nr   r   r   r   r   AABBr   z
            \begin{tabular}{lrl}
            \toprule
             & AA & BB \\
            \midrule
            0 & 1 & b1 \\
            1 & 2 & b2 \\
            \bottomrule
            \end{tabular}
            r4   r5   s       r   )test_to_latex_specified_header_with_indexz;TestToLatexHeader.test_to_latex_specified_header_with_indexL  sL    aV4,78T4L1	
 !!!r   c                 v    t        ddgddgd      }|j                  ddgd	      }t        d
      }||k(  sJ y )Nr   r   r   r   r   r   r   F)r   r;   z
            \begin{tabular}{rl}
            \toprule
            AA & BB \\
            \midrule
            1 & b1 \\
            2 & b2 \\
            \bottomrule
            \end{tabular}
            r4   r5   s       r   ,test_to_latex_specified_header_without_indexz>TestToLatexHeader.test_to_latex_specified_header_without_index^  sN    aV4,78T4L>	
 !!!r   zheader, num_aliasesAr   ))Br   ))Col1Col2Col3r   ))r   r   r   Col4r   c                     t        ddgddgd      }d| d}t        j                  t        |      5  |j	                  |	       d d d        y # 1 sw Y   y xY w)
Nr   r   r   r   r   zWriting 2 cols but got z aliasesrC   r   rG   )r%   r   num_aliasesr.   rK   s        r   8test_to_latex_number_of_items_in_header_missmatch_raiseszJTestToLatexHeader.test_to_latex_number_of_items_in_header_missmatch_raisesp  sQ     aV4,78'}H=]]:S1KKvK& 211s   AAc                 p    t        ddgddgd      }|j                  d      }t        d      }||k(  sJ y )	N      ?g @r   r   r   ,)decimalz
            \begin{tabular}{lrl}
            \toprule
             & a & b \\
            \midrule
            0 & 1,000000 & b1 \\
            1 & 2,100000 & b2 \\
            \bottomrule
            \end{tabular}
            r4   r5   s       r   test_to_latex_decimalz'TestToLatexHeader.test_to_latex_decimal  sH    c3ZtTl;<S)	
 !!!r   N)ro   rp   rq   r   r   r   r   rH   rr   rs   r   r   r   r   r   r   r   )  sX    """""$"$ [[UAJ)1		
	'	'"r   r   c                       e Zd Zd Zd Zy)TestToLatexBoldc                 p    t        ddgddgd      }|j                  d      }t        d      }||k(  sJ y )	Nr   r   r   r   r   T	bold_rowsz
            \begin{tabular}{lrl}
            \toprule
             & a & b \\
            \midrule
            \textbf{0} & 1 & b1 \\
            \textbf{1} & 2 & b2 \\
            \bottomrule
            \end{tabular}
            r4   r5   s       r   test_to_latex_bold_rowsz'TestToLatexBold.test_to_latex_bold_rows  sH    aV4,78t,	
 !!!r   c                 p    t        ddgddgd      }|j                  d      }t        d      }||k(  sJ y )	Nr   r   r   r   r   Fr   r3   r4   r5   s       r   test_to_latex_no_bold_rowsz*TestToLatexBold.test_to_latex_no_bold_rows  sH    aV4,78u-	
 !!!r   N)ro   rp   rq   r   r   r   r   r   r   r     s    "$"r   r   c                   J   e Zd Zej                  d        Zej                  d        Zej                  d        Zej                  d        Zej                  d        Z	d Z
d Zd Zd	 Zd
 Zd Zej                   j#                  dg d      d        Zd Zd Zd Zd Zd Zy)TestToLatexCaptionLabelc                      y)z,Caption for table/tabular LaTeX environment.z/a table in a \texttt{table/tabular} environmentr   r%   s    r   caption_tablez%TestToLatexCaptionLabel.caption_table  s     Br   c                      y)z@Short caption for testing \caption[short_caption]{full_caption}.za tabler   r   s    r   short_captionz%TestToLatexCaptionLabel.short_caption  s     r   c                      y)z*Label for table/tabular LaTeX environment.ztab:table_tabularr   r   s    r   label_tablez#TestToLatexCaptionLabel.label_table  s     #r   c                      y)z(Caption for longtable LaTeX environment.z+a table in a \texttt{longtable} environmentr   r   s    r   caption_longtablez)TestToLatexCaptionLabel.caption_longtable  s     >r   c                      y)z&Label for longtable LaTeX environment.ztab:longtabler   r   s    r   label_longtablez'TestToLatexCaptionLabel.label_longtable  s     r   c                 L    |j                  |      }t        d      }||k(  sJ y )NcaptionaN  
            \begin{table}
            \caption{a table in a \texttt{table/tabular} environment}
            \begin{tabular}{lrl}
            \toprule
             & a & b \\
            \midrule
            0 & 1 & b1 \\
            1 & 2 & b2 \\
            \bottomrule
            \end{tabular}
            \end{table}
            r"   r   )r%   r   r   r6   r7   s        r   test_to_latex_caption_onlyz2TestToLatexCaptionLabel.test_to_latex_caption_only  s4    ""="9
 !!!r   c                 L    |j                  |      }t        d      }||k(  sJ y )N)labela.  
            \begin{table}
            \label{tab:table_tabular}
            \begin{tabular}{lrl}
            \toprule
             & a & b \\
            \midrule
            0 & 1 & b1 \\
            1 & 2 & b2 \\
            \bottomrule
            \end{tabular}
            \end{table}
            r   )r%   r   r   r6   r7   s        r   test_to_latex_label_onlyz0TestToLatexCaptionLabel.test_to_latex_label_only  s4    """5
 !!!r   c                 N    |j                  ||      }t        d      }||k(  sJ y )Nr   r   at  
            \begin{table}
            \caption{a table in a \texttt{table/tabular} environment}
            \label{tab:table_tabular}
            \begin{tabular}{lrl}
            \toprule
             & a & b \\
            \midrule
            0 & 1 & b1 \\
            1 & 2 & b2 \\
            \bottomrule
            \end{tabular}
            \end{table}
            r   )r%   r   r   r   r6   r7   s         r   test_to_latex_caption_and_labelz7TestToLatexCaptionLabel.test_to_latex_caption_and_label  s6    ""="L
  !!!r   c                 P    |j                  ||f      }t        d      }||k(  sJ y )Nr   aW  
            \begin{table}
            \caption[a table]{a table in a \texttt{table/tabular} environment}
            \begin{tabular}{lrl}
            \toprule
             & a & b \\
            \midrule
            0 & 1 & b1 \\
            1 & 2 & b2 \\
            \bottomrule
            \end{tabular}
            \end{table}
            r   )r%   r   r   r   r6   r7   s         r   &test_to_latex_caption_and_shortcaptionz>TestToLatexCaptionLabel.test_to_latex_caption_and_shortcaption  s;     ""M=+I"J
 !!!r   c                 p    d}|j                  |      }|j                  t        |            }||k(  sJ y )N)zLong-long-captionShortr   )r"   list)r%   r   r   result_tupleresult_lists        r   1test_to_latex_caption_and_shortcaption_list_is_okzITestToLatexCaptionLabel.test_to_latex_caption_and_shortcaption_list_is_ok,  s?    0(((9''W'>{***r   c                 R    |j                  ||f|      }t        d      }||k(  sJ y )Nr   a}  
            \begin{table}
            \caption[a table]{a table in a \texttt{table/tabular} environment}
            \label{tab:table_tabular}
            \begin{tabular}{lrl}
            \toprule
             & a & b \\
            \midrule
            0 & 1 & b1 \\
            1 & 2 & b2 \\
            \bottomrule
            \end{tabular}
            \end{table}
            r   )r%   r   r   r   r   r6   r7   s          r   ,test_to_latex_caption_shortcaption_and_labelzDTestToLatexCaptionLabel.test_to_latex_caption_shortcaption_and_label2  sE     """M2 # 
 
  !!!r   bad_caption))full_captionr   extra_string)r   r   r   )r   r   N)r   )Nc                     t        ddgi      }d}t        j                  t        |      5  |j	                  |       d d d        y # 1 sw Y   y xY w)Nr   r   z7`caption` must be either a string or 2-tuple of stringsrC   r   rG   )r%   r   r.   rK   s       r    test_to_latex_bad_caption_raisesz8TestToLatexCaptionLabel.test_to_latex_bad_caption_raisesP  sA     aSz"G]]:S1KKK, 211s   AAc                 L    |j                  d      }t        d      }||k(  sJ y )Nxyr   a!  
            \begin{table}
            \caption{xy}
            \begin{tabular}{lrl}
            \toprule
             & a & b \\
            \midrule
            0 & 1 & b1 \\
            1 & 2 & b2 \\
            \bottomrule
            \end{tabular}
            \end{table}
            r   )r%   r   r6   r7   s       r   test_to_latex_two_chars_captionz7TestToLatexCaptionLabel.test_to_latex_two_chars_captiona  s6     ""4"0
 !!!r   c                 N    |j                  d|      }t        d      }||k(  sJ y )NT)rx   r   ai  
            \begin{longtable}{lrl}
            \caption{a table in a \texttt{longtable} environment} \\
            \toprule
             & a & b \\
            \midrule
            \endfirsthead
            \caption[]{a table in a \texttt{longtable} environment} \\
            \toprule
             & a & b \\
            \midrule
            \endhead
            \midrule
            \multicolumn{3}{r}{Continued on next page} \\
            \midrule
            \endfoot
            \bottomrule
            \endlastfoot
            0 & 1 & b1 \\
            1 & 2 & b2 \\
            \end{longtable}
            r   )r%   r   r   r6   r7   s        r   $test_to_latex_longtable_caption_onlyz<TestToLatexCaptionLabel.test_to_latex_longtable_caption_onlyv  s9     ""T;L"M
0 !!!r   c                 N    |j                  d|      }t        d      }||k(  sJ y )NT)rx   r   a  
            \begin{longtable}{lrl}
            \label{tab:longtable} \\
            \toprule
             & a & b \\
            \midrule
            \endfirsthead
            \toprule
             & a & b \\
            \midrule
            \endhead
            \midrule
            \multicolumn{3}{r}{Continued on next page} \\
            \midrule
            \endfoot
            \bottomrule
            \endlastfoot
            0 & 1 & b1 \\
            1 & 2 & b2 \\
            \end{longtable}
            r   )r%   r   r   r6   r7   s        r   "test_to_latex_longtable_label_onlyz:TestToLatexCaptionLabel.test_to_latex_longtable_label_only  s6    ""T"I
. !!!r   c                 P    |j                  d||      }t        d      }||k(  sJ y )NTrx   r   r   a+  
        \begin{longtable}{lrl}
        \caption{a table in a \texttt{longtable} environment} \label{tab:longtable} \\
        \toprule
         & a & b \\
        \midrule
        \endfirsthead
        \caption[]{a table in a \texttt{longtable} environment} \\
        \toprule
         & a & b \\
        \midrule
        \endhead
        \midrule
        \multicolumn{3}{r}{Continued on next page} \\
        \midrule
        \endfoot
        \bottomrule
        \endlastfoot
        0 & 1 & b1 \\
        1 & 2 & b2 \\
        \end{longtable}
        r   )r%   r   r   r   r6   r7   s         r   )test_to_latex_longtable_caption_and_labelzATestToLatexCaptionLabel.test_to_latex_longtable_caption_and_label  sC     ""%! # 

 
0 !!!r   c                 T    |j                  d||f|      }t        d      }||k(  sJ y )NTr   a  
\begin{longtable}{lrl}
\caption[a table]{a table in a \texttt{longtable} environment} \label{tab:longtable} \\
\toprule
 & a & b \\
\midrule
\endfirsthead
\caption[]{a table in a \texttt{longtable} environment} \\
\toprule
 & a & b \\
\midrule
\endhead
\midrule
\multicolumn{3}{r}{Continued on next page} \\
\midrule
\endfoot
\bottomrule
\endlastfoot
0 & 1 & b1 \\
1 & 2 & b2 \\
\end{longtable}
r   )r%   r   r   r   r   r6   r7   s          r   6test_to_latex_longtable_caption_shortcaption_and_labelzNTestToLatexCaptionLabel.test_to_latex_longtable_caption_shortcaption_and_label  sH     ""&6! # 

 
0 !!!r   N)ro   rp   rq   rH   fixturer   r   r   r   r   r   r   r   r   r   r   rr   rs   r   r   r   r   r   r   r   r   r   r   r     s    ^^B B ^^  ^^# # ^^> > ^^ "("("*"0+"< [[	
	-	-"*">"8$"L%"r   r   c                   N    e Zd Zej                  d        Zd Zd Zd Zd Z	d Z
y)TestToLatexEscapec              #   D   K   d}d}t        |d|di|d|did       yw)z=Dataframe with special characters for testing chars escaping.r   r   )zco$e^x$zco^l1Nr   )r%   r   r   s      r   df_with_symbolsz!TestToLatexEscape.df_with_symbols   s4      QQ$433?OPQQs    c                 L    |j                  d      }t        d      }||k(  sJ y )NFescapez
            \begin{tabular}{lll}
            \toprule
             & co$e^x$ & co^l1 \\
            \midrule
            a & a & a \\
            b & b & b \\
            \bottomrule
            \end{tabular}
            r   )r%   r   r6   r7   s       r   test_to_latex_escape_falsez,TestToLatexEscape.test_to_latex_escape_false  s4     )))7	
 !!!r   c                 V    |j                         }|j                  d      }||k7  sJ y )NTr   rO   )r%   r   defaultspecified_trues       r   test_to_latex_escape_defaultz.TestToLatexEscape.test_to_latex_escape_default  s1    !**,(111>.(((r   c                 f    t        g d      }|j                  d      }t        d      }||k(  sJ y )N)za\b\cz^a^b^cz~a~b~cTr   ac  
            \begin{tabular}{ll}
            \toprule
             & 0 \\
            \midrule
            0 & a\textbackslash b\textbackslash c \\
            1 & \textasciicircum a\textasciicircum b\textasciicircum c \\
            2 & \textasciitilde a\textasciitilde b\textasciitilde c \\
            \bottomrule
            \end{tabular}
            r4   r5   s       r   test_to_latex_special_escapez.TestToLatexEscape.test_to_latex_special_escape  s<    78D)

 !!!r   c                 l    g d}t        |      }|j                  d      }t        d      }||k(  sJ y )N)
&%$#_{r   ~^\)dataTr   a  
            \begin{tabular}{ll}
            \toprule
             & 0 \\
            \midrule
            0 & \& \\
            1 & \% \\
            2 & \$ \\
            3 & \# \\
            4 & \_ \\
            5 & \{ \\
            6 & \} \\
            7 & \textasciitilde  \\
            8 & \textasciicircum  \\
            9 & \textbackslash  \\
            \bottomrule
            \end{tabular}
            r4   )r%   special_charactersr.   r6   r7   s        r   "test_to_latex_escape_special_charsz4TestToLatexEscape.test_to_latex_escape_special_chars/  sB    P./D)
( !!!r   c                 v    t        ddgddgd      }|j                  ddgd	      }t        d
      }||k(  sJ y )Nr   r   r   r   r   z$A$z$B$F)r   r   z
            \begin{tabular}{lrl}
            \toprule
             & $A$ & $B$ \\
            \midrule
            0 & 1 & b1 \\
            1 & 2 & b2 \\
            \bottomrule
            \end{tabular}
            r4   r5   s       r   ;test_to_latex_specified_header_special_chars_without_escapezMTestToLatexEscape.test_to_latex_specified_header_special_chars_without_escapeI  sN    aV4,78UEN5A	
 !!!r   N)ro   rp   rq   rH   r   r   r   r   r   r   r   r   r   r   r   r     s3    ^^R R" )"$"4"r   r   c                       e Zd Zd Zd Zy)TestToLatexPositionc                 t    d}t        ddgddgd      }|j                  |      }t        d      }||k(  sJ y )	Nhr   r   r   r   r   )positiona  
            \begin{table}[h]
            \begin{tabular}{lrl}
            \toprule
             & a & b \\
            \midrule
            0 & 1 & b1 \\
            1 & 2 & b2 \\
            \bottomrule
            \end{tabular}
            \end{table}
            r4   r%   the_positionr.   r6   r7   s        r   test_to_latex_positionz*TestToLatexPosition.test_to_latex_position]  sM    aV4,78l3
 !!!r   c                 v    d}t        ddgddgd      }|j                  d|      }t        d	      }||k(  sJ y )
Ntr   r   r   r   r   T)rx   r   a  
            \begin{longtable}[t]{lrl}
            \toprule
             & a & b \\
            \midrule
            \endfirsthead
            \toprule
             & a & b \\
            \midrule
            \endhead
            \midrule
            \multicolumn{3}{r}{Continued on next page} \\
            \midrule
            \endfoot
            \bottomrule
            \endlastfoot
            0 & 1 & b1 \\
            1 & 2 & b2 \\
            \end{longtable}
            r4   r   s        r    test_to_latex_longtable_positionz4TestToLatexPosition.test_to_latex_longtable_positionq  sO    aV4,78tlC
, !!!r   N)ro   rp   rq   r  r  r   r   r   r   r   \  s    "("r   r   c                   f    e Zd Zd Zd Zd Zej                  j                  dddg      d        Z	y)	TestToLatexFormattersc           	          t        t        ddd      t        ddd      t        ddd      gg dg dg dd	      }d
 d d d d d}|j                  t        |            }t	        d      }||k(  sJ y )Ni  r   r   r>   r   )r          @      @r   r   r   ))r   r   TF)
datetime64floatintobjectc                 $    | j                  d      S )Nz%Y-%m)strftimexs    r   <lambda>zETestToLatexFormatters.test_to_latex_with_formatters.<locals>.<lambda>  s    AJJw$7r   c                     d| ddS )N[z 4.1f]r   r  s    r   r  zETestToLatexFormatters.test_to_latex_with_formatters.<locals>.<lambda>  s    1U)1~r   c                     d| dS )N0xr  r   r  s    r   r  zETestToLatexFormatters.test_to_latex_with_formatters.<locals>.<lambda>  s    r!AZr   c                     d| dS )N-r   r  s    r   r  zETestToLatexFormatters.test_to_latex_with_formatters.<locals>.<lambda>  s    !A5
r   c                     d|  S )Nzindex: r   r  s    r   r  zETestToLatexFormatters.test_to_latex_with_formatters.<locals>.<lambda>  s
    WQC=r   )r  r  r  r  	__index__)
formattersaq  
            \begin{tabular}{llrrl}
            \toprule
             & datetime64 & float & int & object \\
            \midrule
            index: 0 & 2016-01 & [ 1.0] & 0x1 & -(1, 2)- \\
            index: 1 & 2016-02 & [ 2.0] & 0x2 & -True- \\
            index: 2 & 2016-03 & [ 3.0] & 0x3 & -False- \\
            \bottomrule
            \end{tabular}
            )r   r   r"   dictr   )r%   r.   r  r6   r7   s        r   test_to_latex_with_formattersz3TestToLatexFormatters.test_to_latex_with_formatters  s     T1a(T1a(T1a(
 ) /	
 8-'*0

 Z(89

 !!!r   c                 h    t        ddgi      }|j                  d      }t        d      }||k(  sJ y )Nr  gvöE?z%.3frU   z
            \begin{tabular}{lr}
            \toprule
             & x \\
            \midrule
            0 & 0.200 \\
            \bottomrule
            \end{tabular}
            r4   r5   s       r   3test_to_latex_float_format_no_fixed_width_3decimalszITestToLatexFormatters.test_to_latex_float_format_no_fixed_width_3decimals  sB    gY'(&1

 !!!r   c                 h    t        ddgi      }|j                  d      }t        d      }||k(  sJ y )Nr  g      Y@z%.0frU   z
            \begin{tabular}{lr}
            \toprule
             & x \\
            \midrule
            0 & 100 \\
            \bottomrule
            \end{tabular}
            r4   r5   s       r   1test_to_latex_float_format_no_fixed_width_integerzGTestToLatexFormatters.test_to_latex_float_format_no_fixed_width_integer  sA    eW~&&1

 !!!r   na_repNaNTedc                     t        ddgdd ggddg      }|j                  |dj                        }t        d| d	      }||k(  sJ y )
Nr   g(\?GroupData)columnsz{:.2f})r%  rV   z
            \begin{tabular}{llr}
            \toprule
             & Group & Data \\
            \midrule
            0 & A & 1.22 \\
            1 & A & zB \\
            \bottomrule
            \end{tabular}
            )r   r"   rW   r   )r%   r%  r.   r6   r7   s        r   %test_to_latex_na_rep_and_float_formatz;TestToLatexFormatters.test_to_latex_na_rep_and_float_format  sq    fd f%
 FI H 	
 !!!r   N)
ro   rp   rq   r   r"  r$  rH   rr   rs   r,  r   r   r   r  r    s;    $"L"""" [[Xu~6" 7"r   r  c            	          e Zd Zej                  d        Zej                  d        Zd Zd Zd Z	d Z
d Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zej(                  j+                  dddg      ej(                  j+                  dddg      ej(                  j+                  ddgdgddgg      d                      Zej(                  j+                  dddg      d        Zd Zd Zy)TestToLatexMultiindexc              #     K   t        j                  t        t        d      D ci c]  }|| c}      t        t        d      D ci c]  }||dz   
 c}      t        t        d      D ci c]  }|| c}      t        t        d      D ci c]  }||dz   
 c}      t        t        d      D ci c]  }|| c}      d      j                   yc c}w c c}w c c}w c c}w c c}w w)z7Multiindex dataframe for testing multirow LaTeX macros.r   )c1r   )r1  r   )c2r   )r2  r   )c3r   N)r   	from_dictr   rangeTr%   r  s     r   multiindex_framez&TestToLatexMultiindex.multiindex_frame  s      !!!q":A1a4":;!U1X">X1a!e8X">?!q":A1a4":;!U1X">X1a!e8X">?!q":A1a4":;
 !	":">":">":s?   "C/
CC/CC/+
C 5C/C%C/2
C*<3C/c              #   `  K   t        t        d      D ci c]  }|| c}t        d      D ci c]  }||dz   
 c}t        d      D ci c]  }|| c}t        d      D ci c]  }||dz   
 c}t        d      D ci c]  }|| c}d       yc c}w c c}w c c}w c c}w c c}w w)z;Multicolumn dataframe for testing multicolumn LaTeX macros.r>   r0  N)r   r5  r7  s     r   multicolumn_framez'TestToLatexMultiindex.multicolumn_frame  s      */(3(QAqD(3.3Ah7hAq1uHh7*/(3(QAqD(3.3Ah7hAq1uHh7*/(3(QAqD(3
 	
37373s=   B.
BB.B
B.

BB.#B$0B.?
B)	%B.c                     t        dgdgdgdgd      }|j                  ddg      }|j                  dd	gd
      }t        d      }||k(  sJ y )Nr   r   r   r   )r   r   rA   dr   r   r1r2F)r   multirowz
            \begin{tabular}{llrr}
            \toprule
             &  & r1 & r2 \\
            a & b &  &  \\
            \midrule
            0 & 1 & 2 & 3 \\
            \bottomrule
            \end{tabular}
            r   	set_indexr"   r   )r%   r.   observedr7   s       r   test_to_latex_multindex_headerz4TestToLatexMultiindex.test_to_latex_multindex_header  sd    aSs!A3?@\\3*%;;tTlU;C	
 8###r   c                     t         j                  j                  ddggdg      }t        d|t	        d            }|j                         }t        d      }||k(  sJ y )	Nr   r    namesr   r;   r+  a  
            \begin{tabular}{lrrrr}
            \toprule
             & 0 & 1 & 2 & 3 \\
             &  &  &  &  \\
            \midrule
            1 & -1 & -1 & -1 & -1 \\
            2 & -1 & -1 & -1 & -1 \\
            \bottomrule
            \end{tabular}
            )pd
MultiIndexfrom_productr   r5  r"   r   )r%   mir.   rB  r7   s        r   #test_to_latex_multiindex_empty_namez9TestToLatexMultiindex.test_to_latex_multiindex_empty_name  s_    ]]''!Q'=rU1X6;;=

 8###r   c                 d    t        ddgi      }|j                         }t        d      }||k(  sJ y )Nr  yr   z
            \begin{tabular}{ll}
            \toprule
             & x \\
             & y \\
            \midrule
            0 & a \\
            \bottomrule
            \end{tabular}
            r4   r5   s       r   'test_to_latex_multiindex_column_tabularz=TestToLatexMultiindex.test_to_latex_multiindex_column_tabular2  s=    
SE*+	
 !!!r   c                 |    t        ddgi      j                  }|j                  d      }t        d      }||k(  sJ y )NrP  r   Fr?  z
            \begin{tabular}{lll}
            \toprule
             &  & 0 \\
            \midrule
            x & y & a \\
            \bottomrule
            \end{tabular}
            )r   r6  r"   r   r5   s       r   &test_to_latex_multiindex_small_tabularz<TestToLatexMultiindex.test_to_latex_multiindex_small_tabularC  sH    
SE*+--e,

 !!!r   c                 L    |j                  d      }t        d      }||k(  sJ y )NFrT  aj  
            \begin{tabular}{llrrrr}
            \toprule
             &  & 0 & 1 & 2 & 3 \\
            \midrule
            c1 & 0 & 0 & 1 & 2 & 3 \\
             & 1 & 4 & 5 & 6 & 7 \\
            c2 & 0 & 0 & 1 & 2 & 3 \\
             & 1 & 4 & 5 & 6 & 7 \\
            c3 & 0 & 0 & 1 & 2 & 3 \\
            \bottomrule
            \end{tabular}
            r   )r%   r8  r6   r7   s       r    test_to_latex_multiindex_tabularz6TestToLatexMultiindex.test_to_latex_multiindex_tabularS  s4    !**E*:
 !!!r   c                     |j                   }ddg|j                  _        |j                  d      }t	        d      }||k(  sJ y )Nr   r   FrT  a  
            \begin{tabular}{lrrrrr}
            \toprule
            a & \multicolumn{2}{r}{c1} & \multicolumn{2}{r}{c2} & c3 \\
            b & 0 & 1 & 0 & 1 & 0 \\
            \midrule
            0 & 0 & 4 & 0 & 4 & 0 \\
            1 & 1 & 5 & 1 & 5 & 1 \\
            2 & 2 & 6 & 2 & 6 & 2 \\
            3 & 3 & 7 & 3 & 7 & 3 \\
            \bottomrule
            \end{tabular}
            )r6  r+  rG  r"   r   )r%   r8  r.   r6   r7   s        r   !test_to_latex_multicolumn_tabularz7TestToLatexMultiindex.test_to_latex_multicolumn_tabularf  sL    :

e,
 !!!r   c                     t        g dt        d      g dd      }|j                  ddg      j                  d      }t	        d	      }||k(  sJ y )
Nr   r   r   r   ababr   r   r   r   r]   r   r   FrT  a  
            \begin{tabular}{llr}
            \toprule
             &  & c \\
            a & b &  \\
            \midrule
            0 & a & 1 \\
             & b & 2 \\
            1 & a & 3 \\
             & b & 4 \\
            \bottomrule
            \end{tabular}
            )r   r   rA  r"   r   r5   s       r   $test_to_latex_index_has_name_tabularz:TestToLatexMultiindex.test_to_latex_index_has_name_tabular|  sV    \V<PQsCj)22E2B
 !!!r   c                     t        g dt        d      g dd      }|j                  d      j                         j	                  dj
                  d      }t        d	      }||k(  sJ y )
Nr[  r\  r]  r]   r   z{:.1f}T)rV   r   a  
            \begin{tabular}{lrrrrrrrr}
            \toprule
             & \multicolumn{8}{r}{c} \\
             & count & mean & std & min & 25\% & 50\% & 75\% & max \\
            a &  &  &  &  &  &  &  &  \\
            \midrule
            0 & 2.0 & 1.5 & 0.7 & 1.0 & 1.2 & 1.5 & 1.8 & 2.0 \\
            1 & 2.0 & 3.5 & 0.7 & 3.0 & 3.2 & 3.5 & 3.8 & 4.0 \\
            \bottomrule
            \end{tabular}
            )r   r   groupbydescriber"   rW   r   r5   s       r   test_to_latex_groupby_tabularz3TestToLatexMultiindex.test_to_latex_groupby_tabular  sa    \V<PQJJsOXZX8??4X@ 	
 
 !!!r   c                     t        t        j                  j                  ddg      dg      }|j	                  d      }t        d      }||k(  sJ y )N)r   rA   )r   rA   colrI  FrT  z
            \begin{tabular}{lll}
            \toprule
             &  & col \\
            \midrule
            A & c & NaN \\
            B & c & NaN \\
            \bottomrule
            \end{tabular}
            )r   rJ  rK  from_tuplesr"   r   r5   s       r   #test_to_latex_multiindex_dupe_levelz9TestToLatexMultiindex.test_to_latex_multiindex_dupe_level  s[     --++Z,DEPUw
 e,	
 !!!r   c                 H    |j                         }t        d      }||k(  sJ y )Na  
            \begin{tabular}{lrrrrr}
            \toprule
             & \multicolumn{2}{r}{c1} & \multicolumn{2}{r}{c2} & c3 \\
             & 0 & 1 & 0 & 1 & 0 \\
            \midrule
            0 & 0 & 5 & 0 & 5 & 0 \\
            1 & 1 & 6 & 1 & 6 & 1 \\
            2 & 2 & 7 & 2 & 7 & 2 \\
            3 & 3 & 8 & 3 & 8 & 3 \\
            4 & 4 & 9 & 4 & 9 & 4 \\
            \bottomrule
            \end{tabular}
            r   r%   r:  r6   r7   s       r   !test_to_latex_multicolumn_defaultz7TestToLatexMultiindex.test_to_latex_multicolumn_default  s/    "++-
  !!!r   c                 N    |j                  dd      }t        d      }||k(  sJ y )NFr?   )multicolumnmulticolumn_formata  
            \begin{tabular}{lrrrrr}
            \toprule
             & c1 & & c2 & & c3 \\
             & 0 & 1 & 0 & 1 & 0 \\
            \midrule
            0 & 0 & 5 & 0 & 5 & 0 \\
            1 & 1 & 6 & 1 & 6 & 1 \\
            2 & 2 & 7 & 2 & 7 & 2 \\
            3 & 3 & 8 & 3 & 8 & 3 \\
            4 & 4 & 9 & 4 & 9 & 4 \\
            \bottomrule
            \end{tabular}
            r   rh  s       r   test_to_latex_multicolumn_falsez5TestToLatexMultiindex.test_to_latex_multicolumn_false  s7    "++RU+V
  !!!r   c                 `    |j                   j                  d      }t        d      }||k(  sJ y )NTrT  a  
            \begin{tabular}{llrrrrr}
            \toprule
             &  & 0 & 1 & 2 & 3 & 4 \\
            \midrule
            \multirow[t]{2}{*}{c1} & 0 & 0 & 1 & 2 & 3 & 4 \\
             & 1 & 5 & 6 & 7 & 8 & 9 \\
            \cline{1-7}
            \multirow[t]{2}{*}{c2} & 0 & 0 & 1 & 2 & 3 & 4 \\
             & 1 & 5 & 6 & 7 & 8 & 9 \\
            \cline{1-7}
            c3 & 0 & 0 & 1 & 2 & 3 & 4 \\
            \cline{1-7}
            \bottomrule
            \end{tabular}
            )r6  r"   r   rh  s       r   test_to_latex_multirow_truez1TestToLatexMultiindex.test_to_latex_multirow_true  s:    "$$--t-<
$ !!!r   c                     |j                   j                  |_        |j                   j                  ddd      }t        d      }||k(  sJ y )NTrA   )r?  rk  rl  a=  
            \begin{tabular}{llrrrrr}
            \toprule
             &  & \multicolumn{2}{c}{c1} & \multicolumn{2}{c}{c2} & c3 \\
             &  & 0 & 1 & 0 & 1 & 0 \\
            \midrule
            \multirow[t]{2}{*}{c1} & 0 & 0 & 1 & 2 & 3 & 4 \\
             & 1 & 5 & 6 & 7 & 8 & 9 \\
            \cline{1-7}
            \multirow[t]{2}{*}{c2} & 0 & 0 & 1 & 2 & 3 & 4 \\
             & 1 & 5 & 6 & 7 & 8 & 9 \\
            \cline{1-7}
            c3 & 0 & 0 & 1 & 2 & 3 & 4 \\
            \cline{1-7}
            \bottomrule
            \end{tabular}
            )r6  r;   r"   r   rh  s       r   1test_to_latex_multicolumnrow_with_multicol_formatzGTestToLatexMultiindex.test_to_latex_multicolumnrow_with_multicol_format  s\    "3"5"5";";"$$--" . 

 
& !!!r   name0Nnamed0name1named1axesr   r   c                    ||g}t         j                  j                  ddgddgg      }t        d|j	                         |j	                               }|D ]  }||j
                  |   _         t        d |D              }d|v rt        |      r|d    d	|d    d
nd}	|D 
cg c]  }
t        |
      rd|v r|
nd }}
|j                  d      }dt        t        |      |	gz         z  }||k(  sJ y c c}
w )Nr   r   r   r   rH  rI  c              3   (   K   | ]
  }|xs d   yw)rE  Nr   ).0ns     r   	<genexpr>zGTestToLatexMultiindex.test_to_latex_multiindex_names.<locals>.<genexpr>(  s     15a!'r'5s   r   z & z &  &  &  &  \\
rE  FrT  a
  \begin{tabular}{llrrrr}
\toprule
 & %s & \multicolumn{2}{r}{1} & \multicolumn{2}{r}{2} \\
 & %s & 3 & 4 & 3 & 4 \\
%s\midrule
1 & 3 & -1 & -1 & -1 & -1 \\
 & 4 & -1 & -1 & -1 & -1 \\
2 & 3 & -1 & -1 & -1 & -1 \\
 & 4 & -1 & -1 & -1 & -1 \\
\bottomrule
\end{tabular}
)rJ  rK  rL  r   copyrv  rG  tupleanyboolr"   r   )r%   rr  rt  rv  rG  rM  r.   idx	idx_namesidx_names_rowrz  	col_namesrB  r7   s                 r   test_to_latex_multiindex_namesz4TestToLatexMultiindex.test_to_latex_multiindex_names  s   
 ]]''!Q!Q(89rBGGI>C!&BGGCL  1511	 T	c%j |nC	!~-@A 	
 DII5a47qDyQr95	I;;;. O}o-

 8#### Js   $C5one_rowTFc                     t        d dgddgddgd      }|r|j                  dg   }|j                  dd	g      j                  d
      }t	        d      }|s|dz  }|dz  }||k(  sJ y )Nr   r   r   r   r>   r]   r   r   r   FrT  z
            \begin{tabular}{llr}
            \toprule
             &  & c \\
            a & b &  \\
            \midrule
            NaN & 2 & 4 \\
            z1.000000 & 3 & 5 \\
z\bottomrule
\end{tabular}
)r   ilocrA  r"   r   )r%   r  r.   rB  r7   s        r   test_to_latex_multiindex_nansz3TestToLatexMultiindex.test_to_latex_multiindex_nansA  s     dAYaV1a&AB!B<<c
+44e4D	
   H  	 8###r   c                     t        g dgdz        j                  ddg      }|j                  d      }t        d      }||k(  sJ y )Nr  r   r   r   FrT  z
            \begin{tabular}{llr}
            \toprule
             &  & 2 \\
            0 & 1 &  \\
            \midrule
            1 & 2 & 3 \\
             & 2 & 3 \\
            \bottomrule
            \end{tabular}
            r@  r5   s       r   test_to_latex_non_string_indexz4TestToLatexMultiindex.test_to_latex_non_string_indexZ  sP    	{Q'111a&9e,

 !!!r   c                     t         j                  j                  ddgg dddggg d      }t        |      }|j	                  d	d
      }t        d      }||k(  sJ y )Ng        r   )r
  r	  r   01)ival0val1rF  r:   TF)r?  r   aE  
            \begin{tabular}{lll}
            \toprule
            i & val0 & val1 \\
            \midrule
            \multirow[t]{6}{*}{0.000000} & \multirow[t]{2}{*}{3.000000} & 0 \\
             &  & 1 \\
            \cline{2-3}
             & \multirow[t]{2}{*}{2.000000} & 0 \\
             &  & 1 \\
            \cline{2-3}
             & \multirow[t]{2}{*}{1.000000} & 0 \\
             &  & 1 \\
            \cline{1-3} \cline{2-3}
            \multirow[t]{6}{*}{1.000000} & \multirow[t]{2}{*}{3.000000} & 0 \\
             &  & 1 \\
            \cline{2-3}
             & \multirow[t]{2}{*}{2.000000} & 0 \\
             &  & 1 \\
            \cline{2-3}
             & \multirow[t]{2}{*}{1.000000} & 0 \\
             &  & 1 \\
            \cline{1-3} \cline{2-3}
            \bottomrule
            \end{tabular}
            )rJ  rK  rL  r   r"   r   )r%   rM  r.   r6   r7   s        r   !test_to_latex_multiindex_multirowz7TestToLatexMultiindex.test_to_latex_multiindex_multirowm  sm    ]]''3Z3*5=R ( 
 R d59
8 !!!r   )ro   rp   rq   rH   r   r8  r:  rC  rN  rR  rU  rW  rY  r^  rb  rf  ri  rm  ro  rq  rr   rs   r  r  r  r  r   r   r   r.  r.    s   ^^
 
 ^^

 

$&$(""" "&","*"0"4"("(","8 [[WtX&67[[WtX&67[[VqcA3A%78$ 9 8 8$B [[Yu6$ 7$0"&#"r   r.  )r   textwrapr   rH   pandasrJ  r   r   pandas._testing_testingr    importorskipr   r   r   r   ru   r   r   r   r   r   r  r.  r   r   r   <module>r     s           H # 7 7
k$ k$\X? X?vk" k"\#" #"L" "D
Z" Z"z/" /"d_" _"D`" `"r   