a
    d8                     @   s   d dl m Z 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mZmZmZmZmZmZmZ d dlmZ d dlm  m  mZ G dd dZdS )    )datetime	timedelta)StringION)NACategorical	DataFrame
MultiIndexNaTPeriodIndexSeries	Timestamp
date_rangeoption_contextperiod_rangec                   @   sl  e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zejjdd Zdd Zdd Zejjdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zejd1ej ej!gejd2e"d3ge#d4ggd5d6 Z$d7d8 Z%d9d: Z&d;d< Z'd=d> Z(d?d@ Z)dAdB Z*dCdD Z+dEdF Z,dGdH Z-dIdJ Z.dKdL Z/dMS )NTestDataFrameReprInfoEtcc                    s   t d dd} fddt|D }t|d}|jtk sHJ t| t|jd dd d f  t|jd dd d f  d S )	NZACDEFGHIJKLMNOP2     c                    s"   g | ]} fd dt D qS )c                    s   g | ]}t jd  qS )   )nprandomdefault_rngchoice).0x)lets j/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/pandas/tests/frame/test_repr_info.py
<listcomp>#       zPTestDataFrameReprInfoEtc.test_repr_bytes_61_lines.<locals>.<listcomp>.<listcomp>)range)r   _r   slenr   r   r   "   s   zETestDataFrameReprInfoEtc.test_repr_bytes_61_lines.<locals>.<listcomp>ZU1<   =   )	listr   r   astypeZdtypesobjectallrepriloc)selfZnseqswordsdfr   r!   r   test_repr_bytes_61_lines   s    z1TestDataFrameReprInfoEtc.test_repr_bytes_61_linesc                 C   sH   t jddgddgd}ttjdd|d}t||}t	| d S )	N)r   r   )   r/   u   Δi1namesr   )r      index)
r   from_tuplesr   r   r   r   standard_normaltmget_objr)   )r+   Zframe_or_seriesr5   objr   r   r   test_repr_unicode_level_names.   s    z6TestDataFrameReprInfoEtc.test_repr_unicode_level_namesc                 C   sd   t g dg dg ddddg}t|j}d|d< ||_t| d	d
g|d< ||_t| d S )Nr/   r      r3               	   abcrF   rG   )fazboor   rI   rJ   )r   	set_indexr%   r5   r)   )r+   r-   r5   r   r   r   test_assign_index_sequences5   s    
z4TestDataFrameReprInfoEtc.test_assign_index_sequencesc                 C   s@   t dddgittdgddggd}t|}d}||ks<J d S )	NXr/   r   Z20130101rF   rG   r4   z/              X
NaT        a  1
2013-01-01 b  2)r   r	   r   r)   r+   r-   resultexpectedr   r   r   test_repr_with_mi_natD   s    $z.TestDataFrameReprInfoEtc.test_repr_with_mi_natc                 C   s4   t g ddd tjtg}t|}d}||ks0J d S )N)r/   r   r=   r3   Tz'      0
True  1
None  2
NaN   3
NaT   4)r   r   nanr	   r)   rN   r   r   r   test_repr_with_different_nullsJ   s    z7TestDataFrameReprInfoEtc.test_repr_with_different_nullsc              	   C   sL   t jddgd ddgtddgddd	gi}t|d
}t|}d}||ksHJ d S )Nr/   r   r=   r3   r@   rB   TrC   rD   )datazG   NaN  None  NaT  True
0    1     3    6     8
1    2     4    7     9)r   rR   r	   r   r)   )r+   dr-   rO   rP   r   r   r   #test_repr_with_different_nulls_colsU   s
    &
z<TestDataFrameReprInfoEtc.test_repr_with_different_nulls_colsc                 C   sP   t ddidtjidtjidtjiddidtjid}|ddg}t| d S )N)AA0006000ZnuitrX   rW   )AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCZDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDZEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEZFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFrY   rZ   )r   r   rR   rK   r)   )r+   Zdf3Zidfr   r   r   test_multiindex_na_repr_   s    z0TestDataFrameReprInfoEtc.test_multiindex_na_reprc                 C   sN   t jddgg dd}tdddgi|d}t|d	}|d
 dsJJ d S )N)rF   r   foo)rG   r/   barrE   r1   valuer   r/   r4   
r   za 0 foo)r   r6   r   r)   split
startswith)r+   r5   r-   linesr   r   r   test_repr_name_coincideo   s    z0TestDataFrameReprInfoEtc.test_repr_name_coincidec                 C   sj   |}|}t | t | t |j t |j t }|j|d |j|d |jj|d |jj|d d S )Nbuf)r)   Tr   	to_string)r+   Z/multiindex_year_month_day_dataframe_random_dataZ multiindex_dataframe_random_dataZymdframere   r   r   r   test_repr_to_stringy   s    

z,TestDataFrameReprInfoEtc.test_repr_to_stringc                 C   s&   t t  ttdd}t | d S )Nr   r4   )r)   r   r   arange)r+   rh   r   r   r   test_repr_empty   s    
z(TestDataFrameReprInfoEtc.test_repr_emptyc                 C   s    t  }t| |jd|d d S )NFverbosere   )r   r)   info)r+   Zfloat_string_framere   r   r   r   test_repr_mixed   s    z(TestDataFrameReprInfoEtc.test_repr_mixedc                 C   s^   t tjddtddtdd}tj|j	d ddf< tj|j	d ddf< t
| d S )Nr      )rW   Br4      rW   rq   )r   r   r   r   r7   r8   ZmakeStringIndexr   rR   locr)   r+   Zbiggier   r   r   test_repr_mixed_big   s    z,TestDataFrameReprInfoEtc.test_repr_mixed_bigc                 C   s   t  }t| |jd|d |jdgdjd|d |jddgdjd|d tg dd}t| t j|d tdgd	gd
gd}dt|vsJ dt|vsJ dt|vsJ d S )NFrl   rW   columnsrq   )r   r/   r=   rd   za
	bza
	dza
	frw   r5   	za
)r   r)   rn   Zreindexr   )r+   float_framere   no_indexr-   r   r   r   	test_repr   s    z"TestDataFrameReprInfoEtc.test_reprc                 C   s   t ddgddgg}tdd  dt|v s0J W d    n1 sD0    Y  tdd  dt|vsjJ W d    n1 s~0    Y  tdd	  dt|vsJ W d    n1 s0    Y  d S )
Nr/   r   r=   r3   zdisplay.show_dimensionsTz2 rows x 2 columnsFtruncater   r   r)   r+   r-   r   r   r   test_repr_dimensions   s    ..z-TestDataFrameReprInfoEtc.test_repr_dimensionsc                 C   s(   t tdtdtdd}t| d S )N)rp   r3   r3   rp   rx   )r   r   zerosr   r)   rt   r   r   r   test_repr_big   s    z&TestDataFrameReprInfoEtc.test_repr_bigc              
   C   s   t ddgd t dgd ddgd t td dgd itdd}t| tdd t| tdd	d
d t| tddd
d t| t	
  d S )Nr\   r/   r   r]   r4   zdisplay.precisionr=   zdisplay.max_rows
   display.max_columnsr   r   )r   r   todayr   r   rj   r)   fmtZ
set_optionr8   Zreset_display_options)r+   r{   Z
unsortabler   r   r   test_repr_unsortable   s     

	z-TestDataFrameReprInfoEtc.test_repr_unsortablec                 C   sp   d}t d||gi}t|}d}|dd  |ks:J t d||gi}t|}|dd  |kslJ d S )Nu   σσσσrW   z      Ar_   r   )r   r)   r`   rstrip)r+   Zuvalr-   rO   Zex_topr   r   r   test_repr_unicode   s    z*TestDataFrameReprInfoEtc.test_repr_unicodec                 C   s   t ddgi}t| d S )NrW      א)r   strr   r   r   r    test_unicode_string_with_unicode   s    z9TestDataFrameReprInfoEtc.test_unicode_string_with_unicodec                 C   s*   t g dg dg dd}t|j d S )Nr<   r>   rA   )r   u   בrH   )r   r)   rw   r   r   r   r   test_repr_unicode_columns   s    z2TestDataFrameReprInfoEtc.test_repr_unicode_columnsc                 C   sL   t ddgi}d}tjt|d t| W d    n1 s>0    Y  d S )NrW   abcz2^'str' object cannot be interpreted as an integer$match)r   pytestZraises	TypeErrorbytes)r+   r-   msgr   r   r   test_str_to_bytes_raises  s    z1TestDataFrameReprInfoEtc.test_str_to_bytes_raisesc                 C   s6   t tjddtjdgd tdd}t| d S )Nr   )r   rr   Z
aaaaaaaaaarr   Zdtyperv   )r   r   r   r   r7   arrayr'   r)   r   r   r   r   test_very_wide_info_repr	  s
    z1TestDataFrameReprInfoEtc.test_very_wide_info_reprc                 C   sN   t dgdd}tdd  dt|v s,J W d    n1 s@0    Y  d S )Nizl u  Is it possible to modify drop plot codeso that the output graph is displayed in iphone simulator, Is it possible to modify drop plot code so that the output graph is â¨displayed in iphone simulator.Now we are adding the CSV file externally. I want to Call the File through the code..)ZId	StringColr   rr   r   r   r   r   r   r   ,test_repr_column_name_unicode_truncation_bug  s    zETestDataFrameReprInfoEtc.test_repr_column_name_unicode_truncation_bugc                 C   sx   t d d}tdd dd8 tg dg dg}| }||ksFJ W d    n1 sZ0    Y  | d u stJ d S )NZjinja2z{\begin{tabular}{llll}
\toprule
 & 0 & 1 & 2 \\
\midrule
0 & $\alpha$ & b & c \\
1 & 1 & 2 & 3 \\
\bottomrule
\end{tabular}
zstyler.format.escapezstyler.render.reprZlatex)z$\alpha$rG   rH   r<   )r   importorskipr   r   Z_repr_latex_)r+   rP   r-   rO   r   r   r   test_latex_repr%  s    
	*z(TestDataFrameReprInfoEtc.test_latex_reprc                 C   sj   t ddddd}tdddd}t||d	}d
}t||ks@J tt|t|d	}t||ksfJ d S )Nz2011-01-01 09:00Hr?   z
US/Eastern)freqperiodstzz2011-01M)r   r   )dtpz                         dt        p
0 2011-01-01 09:00:00-05:00  2011-01
1 2011-01-01 10:00:00-05:00  2011-02
2 2011-01-01 11:00:00-05:00  2011-03
3 2011-01-01 12:00:00-05:00  2011-04
4 2011-01-01 13:00:00-05:00  2011-05)r   r   r   r)   r   )r+   r   r   r-   expZdf2r   r   r   #test_repr_categorical_dates_periods:  s    z<TestDataFrameReprInfoEtc.test_repr_categorical_dates_periodsargzbox, expectedz0    NaT
dtype: objectz     0
0  NaTc                 C   s&   t ||dgtd}||ks"J d S )Nr	   r   )r)   r'   )r+   r   ZboxrP   rO   r   r   r   test_repr_np_nat_with_objectK  s    z5TestDataFrameReprInfoEtc.test_repr_np_nat_with_objectc                 C   s"   t dtddddi}t| d S )Nyearz1/1/1700r   zA-DEC)r   r   )r   r   r)   r   r   r   r   "test_frame_datetime64_pre1900_reprU  s    z;TestDataFrameReprInfoEtc.test_frame_datetime64_pre1900_reprc                 C   s6   t g ddd}ttjdd|d}|  d S )N)z2011-1z2011-2z2011-3r   )r   r   )r=   r3   r4   )r
   r   r   r   r   r7   rg   )r+   r5   rh   r   r   r   %test_frame_to_string_with_periodindexZ  s    z>TestDataFrameReprInfoEtc.test_frame_to_string_with_periodindexc                 C   sD   t dddgitttdgddgd}| }d}||ks@J d S )NrF   r/   r   Int64r   r4   z      a
<NA>  1
1     2)r   r   Zfrom_arraysr   r   rg   rN   r   r   r   "test_to_string_ea_na_in_multiindexa  s    
z;TestDataFrameReprInfoEtc.test_to_string_ea_na_in_multiindexc                 C   sL   t dtddddi}t|}|jd d d df }t|}||ksHJ d S )Nr   Z2019r   UTC)r   r   r?   )r   r   r)   r*   r+   r-   rP   rO   r   r   r   $test_datetime64tz_slice_non_truncaten  s
    z=TestDataFrameReprInfoEtc.test_datetime64tz_slice_non_truncatec                 C   sR   t ddgddgddggddgd	}|ddg  |d
< d}t|}||ksNJ d S )NrF   rG   rH   rU   efleftrightrv   recordz_  left right     record
0    a     b  [0, a, b]
1    c     d  [1, c, d]
2    e     f  [2, e, f])r   
to_recordsr)   r   r   r   r   $test_to_records_no_typeerror_in_reprv  s
    "z=TestDataFrameReprInfoEtc.test_to_records_no_typeerror_in_reprc                 C   sT   t dtjgddgddggddgd}|ddg  |d	< d
}t|}||ksPJ d S )NrF   rH   rU   r   r   r   r   rv   r   zg  left right       record
0    a   NaN  [0, a, nan]
1    c     d    [1, c, d]
2    e     f    [2, e, f]r   r   rR   r   r)   r   r   r   r   $test_to_records_with_na_record_value  s    z=TestDataFrameReprInfoEtc.test_to_records_with_na_record_valuec                 C   sZ   t ddgtjtjgddggtjdgd}|tjdg  |d< d}t|}||ksVJ d S )	NrF   rG   r   r   r   rv   r   zo   NaN right         record
0    a     b      [0, a, b]
1  NaN   NaN  [1, nan, nan]
2    e     f      [2, e, f]r   r   r   r   r   test_to_records_with_na_record  s     z7TestDataFrameReprInfoEtc.test_to_records_with_na_recordc              	   C   s   d}d}t jt|d tdd\ ttjdgtjtjgddggtjtjgd	}|tjtjg  |d
< t	|}W d    n1 s0    Y  W d    n1 s0    Y  ||ksJ d S )Nzk   NaN  inf         record
0  NaN    b    [0, inf, b]
1  NaN  NaN  [1, nan, nan]
2    e    f      [2, e, f]"use_inf_as_na option is deprecatedr   use_inf_as_naTrG   r   r   rv   r   
r8   Zassert_produces_warningFutureWarningr   r   r   infrR   r   r)   r+   rP   r   r-   rO   r   r   r   %test_to_records_with_inf_as_na_record  s    
Dz>TestDataFrameReprInfoEtc.test_to_records_with_inf_as_na_recordc              	   C   s   d}d}t jt|d tdd\ ttjdgtjtjgddggtjtjgd	}|tjtjg  |d
< t	|}W d    n1 s0    Y  W d    n1 s0    Y  ||ksJ d S )Nzk   NaN  inf         record
0  inf    b    [0, inf, b]
1  NaN  NaN  [1, nan, nan]
2    e    f      [2, e, f]r   r   r   FrG   r   r   rv   r   r   r   r   r   r   test_to_records_with_inf_record  s    
Dz8TestDataFrameReprInfoEtc.test_to_records_with_inf_recordc                 C   sN   t tddgddtddgddd}|jd	jd	jgd
}d}||ksJJ d S )Ng_c97ݚ?g6sӭ?ZFloat64r   r/   r   r   )rF   rG   z{:.2f})
formattersz)      a     b
0  0.12  1.00
1  1.12  2.00)r   r   rg   formatrN   r   r   r   test_masked_ea_with_formatter  s    z6TestDataFrameReprInfoEtc.test_masked_ea_with_formatterc                 C   sF   t d tg dg dd}|j||_d}t||ksBJ d S )NZpyarrowr<   r>   )Zlong_column_nameZcol2zg   long_column_name  col2
0                 1     4
1                 2     5
2                 3     6)r   r   r   rw   r&   r)   )r+   Zany_string_dtyper-   rP   r   r   r   test_repr_ea_columns  s
    
z-TestDataFrameReprInfoEtc.test_repr_ea_columnsN)0__name__
__module____qualname__r.   r;   rL   rQ   rS   rV   r[   rc   ri   rk   ro   r   markZslowru   r}   r   r   r   r   r   r   r   r   r   r   r   Zparametrizer   Z
datetime64Ztimedelta64r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      sV   



r   )r   r   ior   numpyr   r   Zpandasr   r   r   r   r	   r
   r   r   r   r   r   Zpandas._testingZ_testingr8   Zpandas.io.formats.formatformatsr   r   r   r   r   r   r   <module>   s   4