o
    vh                     @   s|   d dl Zd dlZd dlmZ d dlZd dlmZmZ d dl	m
Z dd Zdd Zdd	 Zd
d Zdd Zdd Zdd ZdS )    N)np_version_gt2)	DataFrame
MultiIndexc                 C   s   |   }| j}t|| d S )N)to_numpyvaluestmassert_numpy_array_equal)idxresultexp r   h/var/www/html/hyperkenya/venv/lib/python3.10/site-packages/pandas/tests/indexes/multi/test_conversion.pytest_to_numpy   s   r   c                 C   s   t | }t jdtd}g d|d d < t|| t | }t | }t ||s,J t j| dd}t j| dd}t ||rBJ tsFd S d}tj	t
|d t j| dd W d    d S 1 sbw   Y  d S )	N)   dtype)fooone)r   two)barr   )bazr   )quxr   )r   r   T)copyzGStarting with NumPy 2.0, the behavior of the 'copy' keyword has changedmatchF)npasarrayemptyobjectr   r   may_share_memoryarrayr   assert_produces_warningFutureWarning)r	   r
   expectedresult_copy1result_copy2msgr   r   r   test_array_interface   s    


"r(   c                  C   s  g d} t | }|jdd}t| }t|| | }||_t|| g d} t j| ddgd}|jdd}t| }ddg|_t|| | }||_t|| t | }|jdddgd}t| }ddg|_t|| |jddgd}||_ddg|_t|| d	}tj	t
|d
 |jdd W d    n1 sw   Y  d}tj	t|d
 |jdgd W d    n1 sw   Y  t tdtjdddg}|jdd}tttjddddttjddddd}t|| | }||_t|| |jdddgd}tttjddddttjddddd}t|| |jddgd}||_t|| d S )N))   r   )r)   r   )   r   )r*   r   Findexfirstsecondnames)r,   name)r1   z1'name' must be a list / sequence of column names.r   z<'name' should have same length as number of levels on index.   20130101   )periodsint64r   )r   r)   )r-   r.   )r   from_tuplesto_framer   r   assert_frame_equalr,   columnspytestraises	TypeError
ValueErrorfrom_productrangepd
date_ranger   repeatarangetile)tuplesr,   r
   r$   r'   r   r   r   test_to_frame7   sn   




rG   c                     s   t jtjddddg dtjg dddg d	gg d
d  fddt jD } ttjddddg dtjg dddg d	d
} jdd}|j	
 }t|| | |ks[J d S )N19910905r   z
US/Eastern)r5   tz)r)   r)   r)   r*   r*   r*   )arJ   brK   crL   T)ordered)xrN   yzrN   rO   )datesrJ   rK   rL   r/   c                    s   i | ]\}}| j | jqS r   )levelsr   ).0ir1   mir   r   
<dictcomp>   s    z0test_to_frame_dtype_fidelity.<locals>.<dictcomp>Fr+   )r   from_arraysrA   rB   Categorical	enumerater0   r   r8   dtypesto_dictr   r9   )original_dtypesexpected_dfdf	df_dtypesr   rU   r   test_to_frame_dtype_fidelity   s(   	
ra   c                  C   sF   g d} t jg dg dg dg| d}| j }|| ks!J d S )N)rP   r   rJ   )rJ   rK   rL   )rN   rO   rP   )qwer/   )r   rX   r8   r:   tolist)r$   rV   r
   r   r   r   $test_to_frame_resulting_column_order   s   rf   c                  C   s   ddg} ddg}t j| |d}tjtdd |  W d    n1 s%w   Y  |jdd}t| ||d	}t|| d d
g}t j| |d}tjtdd |  W d    n1 s^w   Y  |jdd}t| |d
d
gd	}t|| d S )N)r)   r*   )r4      rJ   r/   z%Cannot create duplicate column labelsr   T)allow_duplicates)r,   r:   r   )	r   r7   r;   r<   r>   r8   r   r   r9   )datar0   r,   r
   r$   r   r   r   test_to_frame_duplicate_labels   s"   

rj   c                 C   s&   t jddd}|  }t|| d S )Nr   F)tupleize_cols)rA   Indexto_flat_indexr   assert_index_equal)r	   r$   r
   r   r   r   test_to_flat_index   s   ro   )numpyr   r;   pandas.compat.numpyr   pandasrA   r   r   pandas._testing_testingr   r   r(   rG   ra   rf   rj   ro   r   r   r   r   <module>   s    #I
