o
    5³cÁ  ã                   @   sN   d Z ddlZddlZddlmZ ddlmZmZ ddl	m
Z G dd„ dƒZdS )zž
test_insert is specifically for the DataFrame.insert method; not to be
confused with tests with "insert" in their names that are really testing
__setitem__.
é    N)ÚPerformanceWarning)Ú	DataFrameÚIndexc                   @   s<   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )ÚTestDataFrameInsertc                 C   sT  t tj dd¡t d¡g d¢d}| dd|d ¡ t |jt	g d¢ƒ¡ tj
|d |d d	d
 | dd|d ¡ t |jt	g d¢ƒ¡ tj|d |d d	d
 tjtdd | dd|d ¡ W d   ƒ n1 slw   Y  d}tjt|d | dd|d ¡ W d   ƒ n1 sŽw   Y  d|j_| dd|d ¡ |jjdks¨J ‚d S )Né   é   )ÚcÚbÚa)ÚindexÚcolumnsr   Úfoor
   )r   r   r	   r
   F)Úcheck_namesé   Úbarr   )r   r   r   r	   r
   zalready exists©Úmatché   r	   zcannot insert c, already existsÚ	some_nameÚbaz)r   ÚnpÚrandomÚrandnÚarangeÚinsertÚtmÚassert_index_equalr   r   Úassert_series_equalÚassert_almost_equalÚpytestÚraisesÚ
ValueErrorÚname©ÚselfÚdfÚmsg© r'   ú]/var/www/html/gps/gps/lib/python3.10/site-packages/pandas/tests/frame/indexing/test_insert.pyÚtest_insert   s&   ÿÿÿzTestDataFrameInsert.test_insertc                 C   s¼   t dddgiƒ}|ji d}| ddddg¡ |ji d}t|ƒ t ddgddggddgd}t ||¡ | dd	d
dg¡ |ji d}t|ƒ t g d¢g d¢gg d¢d}t ||¡ d S )Nr	   çš™™™™™ñ?çš™™™™™@©r   r   r
   r   r   r   çÍÌÌÌÌÌô?çffffff@)r-   r   r*   )r.   r   r+   )r   r
   r	   )r   Úrenamer   Ústrr   Úassert_frame_equal)r$   r%   ÚresultÚexpectedr'   r'   r(   Útest_insert_column_bug_4032,   s   z/TestDataFrameInsert.test_insert_column_bug_4032c                 C   sz   t ƒ }|jddg d¢dd |jddg d¢dd |jddg d¢dd t g d¢g d	¢g d
¢gg d¢d}t ||¡ d S )Nr   ÚA)ÚgÚhÚiT)Úallow_duplicates)ÚdÚeÚf)r
   r	   r   )r
   r:   r6   )r	   r;   r7   )r   r<   r8   )r5   r5   r5   r,   )r   r   r   r1   )r$   r%   Úexpr'   r'   r(   Útest_insert_with_columns_dups@   s   ÿz1TestDataFrameInsert.test_insert_with_columns_dupsc                 C   sœ   t tj dd¡ƒ}|d }|rd }nt}t |¡ tdƒD ]}|d | ||d < qW d   ƒ n1 s5w   Y  d|jd< |j	d |d d ksLJ ‚d S )Né   r   r   éd   r   éc   )r   r   )
r   r   r   r   r   r   Úassert_produces_warningÚrangeÚvaluesÚiloc)r$   Úusing_array_managerr%   ÚserÚexpected_warningÚnr'   r'   r(   Útest_insert_item_cacheK   s   ÿÿ
z*TestDataFrameInsert.test_insert_item_cachec                 C   s\   t tjjdddddd}t d ¡ t g d¢¡|d< W d   ƒ d S 1 s'w   Y  d S )	Nr   r@   )r   r@   )ÚsizeÚInt64)Údtype)r   r   r   r
   )r   r   r   Úrandintr   rB   Úarray)r$   r%   r'   r'   r(   Útest_insert_EA_no_warning]   s   "ÿz-TestDataFrameInsert.test_insert_EA_no_warningc                 C   s\   t ddgddgdœƒ}d}tjt|d | dd|¡ W d   ƒ d S 1 s'w   Y  d S )	Nr   r   r   r?   )Úcol1Úcol2z5Expected a 1D array, got an array with shape \(2, 2\)r   Únewcol)r   r   r    r!   r   r#   r'   r'   r(   Útest_insert_framed   s
   "ÿz%TestDataFrameInsert.test_insert_frameN)	Ú__name__Ú
__module__Ú__qualname__r)   r4   r>   rJ   rP   rT   r'   r'   r'   r(   r      s    r   )Ú__doc__Únumpyr   r   Úpandas.errorsr   Úpandasr   r   Úpandas._testingÚ_testingr   r   r'   r'   r'   r(   Ú<module>   s    