o
    $j                     @   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)Zto_numpyvaluestmassert_numpy_array_equal)idxresultexp r   k/var/www/html/Deteccion_Ine/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   )Zbazr   )quxr   )r   r   T)copyzGStarting with NumPy 2.0, the behavior of the 'copy' keyword has changedmatchF)npZasarrayemptyobjectr   r   Zmay_share_memoryarrayr   Zassert_produces_warningFutureWarning)r   r	   expectedZresult_copy1Z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)r*   z1'name' must be a list / sequence of column names.r   z<'name' should have same length as number of levels on index.   Z20130101   )periodsZint64r   )r   r"   )r&   r'   )r   from_tuplesto_framer   r   assert_frame_equalr%   columnspytestraises	TypeError
ValueErrorZfrom_productrangepd
date_ranger   repeatZarangeZtile)Ztuplesr%   r	   r   r    r   r   r   test_to_frame7   sn   




r:   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 )NZ19910905r   z
US/Eastern)r-   tz)r"   r"   r"   r#   r#   r#   )ar<   br=   cr>   T)ordered)xr@   yzr@   rA   )datesr<   r=   r>   r(   c                    s   i | ]\}}| j | jqS r   )Zlevelsr   ).0ir*   mir   r   
<dictcomp>   s    z0test_to_frame_dtype_fidelity.<locals>.<dictcomp>Fr$   )r   from_arraysr7   r8   ZCategorical	enumerater)   r   r/   Zdtypesto_dictr   r0   )Zoriginal_dtypesZexpected_dfZdfZ	df_dtypesr   rF   r   test_to_frame_dtype_fidelity   s(   	
rL   c                  C   sF   g d} t jg dg dg dg| d}| j }|| ks!J d S )N)rB   r   r<   )r<   r=   r>   )r@   rA   rB   )qwer(   )r   rI   r/   r1   tolist)r   rG   r	   r   r   r   $test_to_frame_resulting_column_order   s   rQ   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#   )r,      r<   r(   z%Cannot create duplicate column labelsr   T)Zallow_duplicates)r%   r1   r   )	r   r.   r2   r3   r5   r/   r   r   r0   )datar)   r%   r	   r   r   r   r   test_to_frame_duplicate_labels   s"   

rT   c                 C   s&   t jddd}|  }t|| d S )Nr   F)Ztupleize_cols)r7   IndexZto_flat_indexr   Zassert_index_equal)r   r   r	   r   r   r   test_to_flat_index   s   rV   )numpyr   r2   Zpandas.compat.numpyr   Zpandasr7   r   r   Zpandas._testingZ_testingr   r   r!   r:   rL   rQ   rT   rV   r   r   r   r   <module>   s    #I
