o
    5c0$                     @   s  d dl m Z  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
mZmZ dd Zdd	 Zd
d Zejddddgdfddgdfdd dgdfdddgdfddgdfddgdfg	d d! Zejdd"dgid#fddgd$d%gd&d'fddgd(dgd&d)fgd*d+ Zejd,g d-d.d/ Zd0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Zd:d; Zd<d= Zd>d? Zd@dA ZdBdC ZdDdE ZejdFdGdHgdIdJ Z ejdKddLgdMdNgdOdPfdQdRgej!dSgdOdTfej!dgdUdVgdQdWgdXdYfgdZd[ Z"dS )\    )datetime)StringIO)dedentN)	DataFrameSeriesoption_contextto_datetimec                  C   sb   t jddtfgd} tt| D ]}t j|| d |< qt| }t|d  t| |	  d S )N
   errdtype)
npemptyobjectrangelenrandomrandnr   repr	to_string)arridf r   \/var/www/html/gps/gps/lib/python3.10/site-packages/pandas/tests/io/formats/test_to_string.pytest_repr_embedded_ndarray   s   r   c                  C   s>   t  } tdtttdtdi}t| |jd| d d S )Ntupsr	   )	col_spacebuf)r   r   listzipr   r   r   )r   r   r   r   r   test_repr_tuples   s   r!   c                  C   s   t ddddddddddg} | g d |  dksJ td	d
 |  dks-J W d    n1 s7w   Y  | jd
ddksFJ d S )NfoobarzXlet's make this a very VERY long line that is longer than the default 50 character limit   )abcdstuff)r%   r&   r'   a:       a    b                                                                                         c  d
0  foo  bar  let's make this a very VERY long line that is longer than the default 50 character limit  1
1  foo  bar                                                                                     stuff  1max_colwidth   )r*   zk     a    b                    c  d
0  foo  bar  let's make this ...  1
1  foo  bar                stuff  1)r   	set_indexr   r   )r   r   r   r   test_to_string_truncate#   s*   


r-   zinput_array, expected)r%   r%   r%   r&   za
br$   z1
a)r$   1z 0
-1)      ?z1.0z az bz a
 bz.1r.   z.1
 110z-10z 10
-10c                 C       t | jdd}||ksJ d S NF)index)r   r   )input_arrayexpectedsr   r   r   'test_format_remove_leading_space_seriesK   s   r8   AzA
ar'   dd)r9   BzA  B
a  c
b ddaazA  B
a aa
1  1c                 C   r2   r3   r   r   )r5   r6   r   r   r   r   *test_format_remove_leading_space_dataframe_   s   
r>   zmax_cols, max_rows, expected))r	   Nz 0   1   2   3   4   ...  6   7   8   9   10
  0   0   0   0   0  ...   0   0   0   0   0
  0   0   0   0   0  ...   0   0   0   0   0
  0   0   0   0   0  ...   0   0   0   0   0
  0   0   0   0   0  ...   0   0   0   0   0)N   z 0   1   2   3   4   5   6   7   8   9   10
  0   0   0   0   0   0   0   0   0   0   0
 ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..
  0   0   0   0   0   0   0   0   0   0   0)r	   r?   z 0   1   2   3   4   ...  6   7   8   9   10
  0   0   0   0   0  ...   0   0   0   0   0
 ..  ..  ..  ..  ..  ...  ..  ..  ..  ..  ..
  0   0   0   0   0  ...   0   0   0   0   0)	   r?   z 0   1   2   3   ...  7   8   9   10
  0   0   0   0  ...   0   0   0   0
 ..  ..  ..  ..  ...  ..  ..  ..  ..
  0   0   0   0  ...   0   0   0   0)r$   r$   z 0  ...
 0  ...
..  ...c                 C   s0   t dgd gd }|jd| |d|ksJ d S )Nr         F)r4   max_colsmax_rowsr=   )rC   rD   r6   r   r   r   r   test_truncation_no_indexm   s   ,rE   c                 C   s`   t dtdi}t }|j|d |  t }|j|d |  |  }t|ts.J d S )Nu   σg      $@)r   )	r   r   aranger   r   getvalueinfo
isinstancestr)float_framer   r   resultr   r   r   test_to_string_unicode_columns   s   rM   c                  C   sR   d  } tdd tddg| gd}t| W d    d S 1 s"w   Y  d S )Nu   אzdisplay.max_rowsr$   r?   columns)encoder   r   r   )nr   r   r   r   test_to_string_utf8_columns   s
   
"rR   c                  C   s    t dg i} t }| | d S )N   c/σr   r   r   dmr   r   r   r   test_to_string_unicode_two   s   rW   c                  C   s   t dg} t }| | d S )N   ÂrT   rU   r   r   r   test_to_string_unicode_three   s   
rY   c                  C   s   t g dg dg ddg dd} ddd fd	d
d fddd fg}| jt|d}| jtt| d d}|dks=J ||ksCJ d S )Nr$   r?      )r0   g       @g      @))r$   r?   TF)intfloatr   rN   r\   c                 S   s   d| dS )N0xxr   r_   r   r   r   <lambda>       z0test_to_string_with_formatters.<locals>.<lambda>r]   c                 S   s   d| ddS )N[z 4.1f]r   r`   r   r   r   ra      s    r   c                 S   s   d| dS )N-r   r`   r   r   r   ra      rb   
formattersr$   z[  int  float    object
0 0x1 [ 1.0]  -(1, 2)-
1 0x2 [ 2.0]    -True-
2 0x3 [ 3.0]   -False-)r   r   dictr   r    )r   rg   rL   result2r   r   r   test_to_string_with_formatters   s"   



rj   c                  C   sX   t dddt dddg} td| i}dd }|jd|id}td}| |ks*J d S )	Ni  r$   r?   monthsc                 S   
   |  dS )Nz%Y-%mstrftimer`   r   r   r   format_func      
zBtest_to_string_with_datetime64_monthformatter.<locals>.format_funcrf   z2        months
        0 2016-01
        1 2016-02)r   r   r   r   strip)rk   r_   ro   rL   r6   r   r   r   -test_to_string_with_datetime64_monthformatter   s   rr   c                  C   sL   t dtddgddi} dd }| jd|id}td	}| |ks$J d S )
Nhodz10:10:10.100z12:12:12.120z%H:%M:%S.%f)formatc                 S   rl   )Nz%H:%Mrm   r`   r   r   r   ro      rp   zAtest_to_string_with_datetime64_hourformatter.<locals>.format_funcrf   z+        hod
        0 10:10
        1 12:12)r   r   r   r   rq   )r_   ro   rL   r6   r   r   r   ,test_to_string_with_datetime64_hourformatter   s   ru   c                  C   s8   t dg di} | jdtid}td}||ksJ d S )NrS   rZ   rf   u8             c/σ
        0   1
        1   2
        2   3)r   r   rJ   r   )r   rL   r6   r   r   r   &test_to_string_with_formatters_unicode   s   rv   c                  C   s,   t g d} |  }td}||ksJ d S )N)      ?      ?rw   y?      ?zG        0    1.00+1.00j
        1    1.00+1.00j
        2    1.05+1.00jr   r   r   )r7   rL   r6   r   r   r   )test_to_string_complex_number_trims_zeros
  s   ry   c                 C   4   | }t g d|d}| }td}||ksJ d S )N)g        r0   Nr   z5        0     0.0
        1     1.0
        2    <NA>rx   )float_ea_dtyper   r7   rL   r6   r   r   r   test_nullable_float_to_string     r|   c                 C   rz   )N)r   r$   Nr   z5        0       0
        1       1
        2    <NA>rx   )any_int_ea_dtyper   r7   rL   r6   r   r   r   test_nullable_int_to_string$  r}   r   na_repNaNTedc                 C   sJ   t ddgdd ggddgd}|j| djd}td|  }||ks#J d S )	Nr9   g(\?GroupDatarN   z{:.2f})r   float_formatzA           Group  Data
         0     A  1.22
         1     A   )r   r   rt   r   )r   r   rL   r6   r   r   r   &test_to_string_na_rep_and_float_format2  s   r   zdata,expectedr?   r[   rB   )col1col2z)   col1  col2
0     1     3
1     2     4Abcgx&1?gC,@z2    col1    col2
0    Abc     NaN
1  0.756  4.5435g;On?gMbX@   )r   r   col3z8  col1   col2 col3
0  NaN  0.009  Abc
1    a  3.543   23c                 C   s"   t | djdd}||ksJ d S )N)datar   )rD   r=   )r   r6   rL   r   r   r   test_to_string_max_rows_zero@  s   r   )#r   ior   textwrapr   numpyr   pytestpandasr   r   r   r   r   r!   r-   markparametrizer8   r>   rE   rM   rR   rW   rY   rj   rr   ru   rv   ry   r|   r   r   nanr   r   r   r   r   <module>   s~    (








+
