o
    gH                     @   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	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 sw   Y  d|j_|dd|d  |jjdksJ 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%   e/home/ubuntu/cloudmapper/venv/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
   r8   r4   )r	   r9   r5   )r   r:   r6   )r3   r3   r3   r*   )r   r   r   r/   )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_cacheN)__name__
__module____qualname__r'   r2   r<   rH   r%   r%   r%   r&   r      s
    r   )__doc__numpyr   r   pandas.errorsr   pandasr   r   pandas._testing_testingr   r   r%   r%   r%   r&   <module>   s    