o
    h.B                     @   sh  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 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mZmZ d dlmZ G dd dZejdd	ed
dgg dfd	ed
dgg dfded
dgg dfded
dgg dfded
dgg dfdeejejdgg dfdedejdgg dfdeejddgg dfgejdddgdd ZdS )     )datetime	timedelta)StringION)using_pyarrow_string_dtype)NACategoricalCategoricalIndex	DataFrameIntervalIndex
MultiIndexNaTPeriodIndexSeries	Timestamp
date_rangeoption_contextperiod_rangec                   @   s  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dd Zejjdd Zejje dd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/d0 Zd1d2 Zd3d4 Z d5d6 Z!d7d8 Z"d9d: Z#d;d< Z$ej%d=e&j'e&j(gej%d>e)d?ge*d@ggdAdB Z+dCdD Z,dEdF Z-dGdH Z.dIdJ Z/dKdL Z0dMdN Z1dOdP Z2dQdR Z3dSdT Z4dUdV Z5dWdX Z6dYS )ZTestDataFrameReprc                 C   s\   g d}g d}dg}t |||d}t| tu sJ ||d  }t| tu s,J d S )N)         r   )u   σu   τu   υu   φu   ψcolumnsindexr   )r	   type__repr__str)selfdataindex1colsdfser r#   p/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/pandas/tests/frame/test_repr.pytest_repr_should_return_str   s   z-TestDataFrameRepr.test_repr_should_return_strc                 C   s|   t d}tjd|d}t|d}|jtk	 sJ t
| t
|jd dd d f  t
|jd dd d f  d S )NACDEFGHIJKLMNOP   )  2   U1<   =   )listnprandomdefault_rngchoicer	   astypedtypesobjectallrepriloc)r   letswordsr!   r#   r#   r$   test_repr_bytes_61_lines.   s   z*TestDataFrameRepr.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'      r   )
r   from_tuplesr	   r.   r/   r0   standard_normaltmget_objr6   )r   frame_or_seriesr   objr#   r#   r$   test_repr_unicode_level_names:   s   z/TestDataFrameRepr.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'   r   r?   r         r   	   abcrO   rP   )fazboor   rR   rS   )r	   	set_indexr-   r   r6   )r   r!   r   r#   r#   r$   test_assign_index_sequencesA   s   
z-TestDataFrameRepr.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'   20130101rO   rP   r@   z/              X
NaT        a  1
2013-01-01 b  2)r	   r   r   r6   r   r!   resultexpectedr#   r#   r$   test_repr_with_mi_natP   s   $z'TestDataFrameRepr.test_repr_with_mi_natc                 C   s4   t g ddd tjtg}t|}d}||ksJ d S )Nr;   r'   r   r?   Tz'      0
True  1
None  2
NaN   3
NaT   4)r	   r.   nanr   r6   rX   r#   r#   r$   test_repr_with_different_nullsV   s   z0TestDataFrameRepr.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s$J d S )Nr;   r'   r   r?   rJ   rL   Tr   rM   )r   zG   NaN  None  NaT  True
0    1     3    6     8
1    2     4    7     9)r.   r]   r   r	   r6   )r   dr!   rY   rZ   r#   r#   r$   #test_repr_with_different_nulls_colsa   s
   &
z5TestDataFrameRepr.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A0006000nuitrb   ra   )AAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFrd   rf   )r	   r.   r]   rT   r6   )r   df3idfr#   r#   r$   test_multiindex_na_reprk   s   z)TestDataFrameRepr.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s%J d S )N)rO   r   foo)rP   r;   barrN   r=   valuer   r;   r@   
r'   za 0 foo)r   rA   r	   r6   split
startswith)r   r   r!   linesr#   r#   r$   test_repr_name_coincide{   s   z)TestDataFrameRepr.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)r6   Tr   	to_string)r   /multiindex_year_month_day_dataframe_random_data multiindex_dataframe_random_dataymdframeru   r#   r#   r$   test_repr_to_string   s   

z%TestDataFrameRepr.test_repr_to_stringc                 C   s&   t t  ttdd}t | d S )Nr(   r@   )r6   r	   r.   arange)r   r{   r#   r#   r$   test_repr_empty   s   
z!TestDataFrameRepr.test_repr_emptyc                 C   s   t | d S )N)r6   )r   float_string_framer#   r#   r$   test_repr_mixed   s   z!TestDataFrameRepr.test_repr_mixedc                 C   sf   t tjdddd tdD dtdd}tj|jd ddf< tj|jd dd	f< t| d S )
Nr'      c                 S   s   g | ]}t |qS r#   )r   ).0ir#   r#   r$   
<listcomp>   s    z9TestDataFrameRepr.test_repr_mixed_big.<locals>.<listcomp>)ra   Br@      ra   r   )	r	   r.   r/   r0   rB   ranger]   locr6   r   biggier#   r#   r$   test_repr_mixed_big   s   z%TestDataFrameRepr.test_repr_mixed_bigz/r in)reasonc                 C   s^   t g dd}t| t dgdgdgd}dt|vsJ dt|vs%J d	t|vs-J d S )
N)r   r;   r   r   za
	bza
	dza
	fr   	za
)r	   r6   )r   no_indexr!   r#   r#   r$   	test_repr   s   zTestDataFrameRepr.test_reprc                 C   s   t ddgddgg}tdd dt|v sJ W d    n1 s"w   Y  tdd dt|vs5J W d    n1 s?w   Y  tdd	 dt|vsRJ W d    d S 1 s]w   Y  d S )
Nr;   r'   r   r?   zdisplay.show_dimensionsTz2 rows x 2 columnsFtruncater	   r   r6   r   r!   r#   r#   r$   test_repr_dimensions   s   "z&TestDataFrameRepr.test_repr_dimensionsc                 C   s(   t tdtdtdd}t| d S )N)r   r?   r?   r   r   )r	   r.   zerosr   r6   r   r#   r#   r$   test_repr_big   s   zTestDataFrameRepr.test_repr_bigc              
   C   sV   t ddgd t dgd ddgd t td dgd itdd}t| d S )Nrm   r;   r)   rn   r@   )r	   r   todayr   r.   r}   r6   )r   
unsortabler#   r#   r$   test_repr_unsortable   s   

	z&TestDataFrameRepr.test_repr_unsortablec                 C   s   t | tdd t | W d    n1 sw   Y  tdddd t | W d    n1 s3w   Y  tdddd t | W d    d S 1 sOw   Y  d S )Nzdisplay.precisionr   zdisplay.max_rows
   display.max_columnsr'   r(   )r6   r   )r   float_framer#   r#   r$   test_repr_float_frame_options   s   


"z/TestDataFrameRepr.test_repr_float_frame_optionsc                 C   sp   d}t d||gi}t|}d}|dd  |ksJ t d||gi}t|}|dd  |ks6J d S )Nu   σσσσra   z      Arp   r   )r	   r6   rq   rstrip)r   uvalr!   rY   ex_topr#   r#   r$   test_repr_unicode   s   z#TestDataFrameRepr.test_repr_unicodec                 C   s   t ddgi}t| d S )Nra      א)r	   r   r   r#   r#   r$    test_unicode_string_with_unicode   s   z2TestDataFrameRepr.test_unicode_string_with_unicodec                 C   s*   t g dg dg dd}t|j d S )NrH   rI   rK   )r   u   בrQ   )r	   r6   r   r   r#   r#   r$   test_repr_unicode_columns   s   z+TestDataFrameRepr.test_repr_unicode_columnsc                 C   sN   t ddgi}d}tjt|d t| W d    d S 1 s w   Y  d S )Nra   abcz2^'str' object cannot be interpreted as an integer$match)r	   pytestraises	TypeErrorbytes)r   r!   msgr#   r#   r$   test_str_to_bytes_raises   s
   
"z*TestDataFrameRepr.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   r   
aaaaaaaaaar   dtyper   )r	   r.   r/   r0   rB   arrayr4   r6   r   r#   r#   r$   test_very_wide_repr  s
   z%TestDataFrameRepr.test_very_wide_reprc                 C   sP   t dgdd}tdd dt|v sJ W d    d S 1 s!w   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..)Id	StringColr   r   r   r   r   r#   r#   r$   ,test_repr_column_name_unicode_truncation_bug  s   "z>TestDataFrameRepr.test_repr_column_name_unicode_truncation_bugc                 C   sx   t d d}tdd dd tg dg dg}| }||ks#J W d    n1 s-w   Y  | d u s:J d S )N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.reprlatex)z$\alpha$rP   rQ   rH   )r   importorskipr   r	   _repr_latex_)r   rZ   r!   rY   r#   r#   r$   test_latex_repr!  s   
	z!TestDataFrameRepr.test_latex_reprc                 C   s8   t dg ditdddd}t|}d}||ksJ d S )Nra   rH   2000r   )periodsr@   z7            A
2000-01-01  1
2000-01-02  2
2000-01-03  3r	   r   r6   rX   r#   r#   r$   test_repr_with_datetimeindex6     z.TestDataFrameRepr.test_repr_with_datetimeindexc                 C   s:   t dg ditg dd}t|}d}||ksJ d S )Nra   r\   )r   r;   r'   r   r?   r@   z1        A
(0, 1]  1
(1, 2]  2
(2, 3]  3
(3, 4]  4)r	   r
   from_breaksr6   rX   r#   r#   r$   test_repr_with_intervalindex<  s   z.TestDataFrameRepr.test_repr_with_intervalindexc                 C   s8   t dg ditg dd}t|}d}||ksJ d S )Nra   rH   rN   r@   z   A
a  1
b  2
c  3)r	   r   r6   rX   r#   r#   r$    test_repr_with_categorical_indexE  r   z2TestDataFrameRepr.test_repr_with_categorical_indexc                 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s3J d S )Nz2011-01-01 09:00hr   z
US/Eastern)freqr   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	   r6   r   )r   r   r   r!   expdf2r#   r#   r$   #test_repr_categorical_dates_periodsK  s   z5TestDataFrameRepr.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   )r6   r4   )r   r   boxrZ   rY   r#   r#   r$   test_repr_np_nat_with_object\  s   z.TestDataFrameRepr.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YE-DEC)r   r   r   r   r#   r#   r$   "test_frame_datetime64_pre1900_reprf  s   z4TestDataFrameRepr.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   r?   r@   )r   r	   r.   r/   r0   rB   rw   )r   r   r{   r#   r#   r$   %test_frame_to_string_with_periodindexk  s   z7TestDataFrameRepr.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 )NrO   r;   r'   Int64r   r@   z      a
<NA>  1
1     2)r	   r   from_arraysr   r   rw   rX   r#   r#   r$   "test_to_string_ea_na_in_multiindexr  s   
z4TestDataFrameRepr.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s$J d S )Nx2019r   UTC)r   r   r   )r	   r   r6   r7   r   r!   rZ   rY   r#   r#   r$   $test_datetime64tz_slice_non_truncate  s
   z6TestDataFrameRepr.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s'J d S )NrO   rP   rQ   r_   efleftrightr   recordz_  left right     record
0    a     b  [0, a, b]
1    c     d  [1, c, d]
2    e     f  [2, e, f])r	   
to_recordsr6   r   r#   r#   r$   $test_to_records_no_typeerror_in_repr  s
   "z6TestDataFrameRepr.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s(J d S )NrO   rQ   r_   r   r   r   r   r   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.   r]   r   r6   r   r#   r#   r$   $test_to_records_with_na_record_value  s   z6TestDataFrameRepr.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s+J d S )	NrO   rP   r   r   r   r   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    z0TestDataFrameRepr.test_to_records_with_na_recordc              	   C      d}d}t jt|dC 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 sBw   Y  W d    n1 sQw   Y  ||ks\J d S )Nk   NaN  inf         record
0  inf    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_naTrP   r   r   r   r   
rC   assert_produces_warningFutureWarningr   r	   r.   infr]   r   r6   r   rZ   r   r!   rY   r#   r#   r$   %test_to_records_with_inf_as_na_record     

z7TestDataFrameRepr.test_to_records_with_inf_as_na_recordc              	   C   r   )Nr   r   r   r   FrP   r   r   r   r   r   r   r#   r#   r$   test_to_records_with_inf_record  r   z1TestDataFrameRepr.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s%J d S )Ng_c97ݚ?g6sӭ?Float64r   r;   r'   r   )rO   rP   z{:.2f})
formattersz)      a     b
0  0.12  1.00
1  1.12  2.00)r	   r   rw   formatrX   r#   r#   r$   test_masked_ea_with_formatter  s   z/TestDataFrameRepr.test_masked_ea_with_formatterc                 C   sF   t d tg dg dd}|j||_d}t||ks!J d S )NpyarrowrH   rI   )long_column_namecol2zg   long_column_name  col2
0                 1     4
1                 2     5
2                 3     6)r   r   r	   r   r2   r6   )r   any_string_dtyper!   rZ   r#   r#   r$   test_repr_ea_columns  s
   
z&TestDataFrameRepr.test_repr_ea_columnsN)7__name__
__module____qualname__r%   r:   rG   rU   r[   r^   r`   rl   rt   r|   r~   r   r   markslowr   xfailr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   parametrizer.   
datetime64timedelta64r   r	   r   r   r   r   r   r   r   r   r   r   r   r   r#   r#   r#   r$   r      sd    





	r   zdata,outputr'   r]   r;   )	 2.0+0.0j	 NaN+0.0jz	 1.0+0.0j)r  r  	-1.0+0.0j)z	-2.0+0.0jr  r  y       Gz)-0.00-1.23j  NaN+0.00jz-1.00+0.00jy        Gz?gGz?)z 0.00+1.23jr	  z 1.23+0.00j)r  z  NaN+ NaNj 1.00+0.00jg333333?)r  z 1.20+ NaNjr
  g333333)r  z  NaN-1.20jr
  as_frameTFc                 C   s   t t| }|r+|jdd}dd t|D }ddt|d  dd| }ndd t|D }d|d	 }t||ksMJ dt| d
| d S )Nval)namec                 S      g | ]\}}| d | qS ) r#   r   r   r  r#   r#   r$   r         z/test_repr_with_complex_nans.<locals>.<listcomp>z >r   rp   c                 S   r  )z   r#   r  r#   r#   r$   r     r  z
dtype: complex128z

)r   r.   r   to_frame	enumeratelenjoinr   )r   outputr  rF   reprsrZ   r#   r#   r$   test_repr_with_complex_nans  s   &(r  ) r   r   ior   numpyr.   r   pandas._configr   pandasr   r   r   r	   r
   r   r   r   r   r   r   r   r   pandas._testing_testingrC   r   r   r   complexr]   r  r#   r#   r#   r$   <module>   s>    <   M