a
    PfQ                     @   sJ   d dl Zd dlZd dlmZmZ d dlmZ d dl	m
Z
 G dd dZdS )    N)Index
date_rangecartesian_productc                   @   s   e Zd Zdd Zdd Zdd Zdd Zej	d	g g gd
dgg gg g dggdd Z
dd Zej	dddgddgdgdgddgddgdgdggdd Zdd ZdS )TestCartesianProductc                 C   sZ   t dddg }}t||g\}}tg d}tg d}t|| t|| d S )NABC      )Ar
   Br   Cr   )r   r	   r   r	   r   r	   )listr   nparraytmassert_numpy_array_equal)selfxyresult1result2	expected1	expected2 r   W/var/www/ai-form-bot/venv/lib/python3.9/site-packages/pandas/tests/reshape/test_util.pytest_simple   s    z TestCartesianProduct.test_simplec                 C   sf   t ddd}dd t||gD \}}tg dtjd}tg dtjd}t|| t|| d S )	N
2000-01-01   )periodsc                 s   s   | ]}t |jV  qd S N)r   day).0r   r   r   r   	<genexpr>       z:TestCartesianProduct.test_datetimeindex.<locals>.<genexpr>)r   r   r   r   dtype)r   r   r   r   )r   r   r   r   Zint32r   assert_index_equal)r   r   r   r   r   r   r   r   r   test_datetimeindex   s    z'TestCartesianProduct.test_datetimeindexc                 C   sF   t dddd}tddg}t||g\}}|d}t|| d S )Nr   r   
US/Pacificr   tz      )r   r   r   r   repeatr   r&   r   r   r   r   r   expectedr   r   r   test_tzaware_retained   s
    
z*TestCartesianProduct.test_tzaware_retainedc                 C   sL   t ddddd}tddg}t||g\}}|d}t|| d S )Nr   r   r(   r)   categoryr+   r,   )r   Zastyper   r   r   r-   r   r&   r.   r   r   r   !test_tzaware_retained_categorical'   s
    
z6TestCartesianProduct.test_tzaware_retained_categoricalzx, yr   r   )abcc                 C   sX   t jg t |jd}t jg t |jd}t||g\}}t|| t|| d S )Nr$   )r   r   Zasarrayr%   r   r   r   )r   r   r   r   r   r   r   r   r   r   
test_empty/   s
    zTestCartesianProduct.test_emptyc                 C   s   t g }g }||ksJ d S r   r   )r   resultr/   r   r   r   test_empty_input8   s    z%TestCartesianProduct.test_empty_inputXr   r3   r4   c                 C   s@   d}t jt|d t|d W d    n1 s20    Y  d S )Nz'Input must be a list-like of list-likesmatchr9   )pytestraises	TypeErrorr   )r   r9   msgr   r   r   test_invalid_input>   s    z'TestCartesianProduct.test_invalid_inputc                 C   sd   d}t jt|d> dd tdD tjdtjdg }t|d W d    n1 sV0    Y  d S )	Nz+Product space too large to allocate arrays!r:   c                 S   s   g | ]}t jd dt jdqS )r   r	   r$   )r   arangeint16)r!   ir   r   r   
<listcomp>L   r#   zBTestCartesianProduct.test_exceed_product_space.<locals>.<listcomp>   i;  r$   r<   )r=   r>   
ValueErrorranger   rB   rC   r   )r   r@   dimsr   r   r   test_exceed_product_spaceG   s    z.TestCartesianProduct.test_exceed_product_spaceN)__name__
__module____qualname__r   r'   r0   r2   r=   markZparametrizer6   r8   rA   rJ   r   r   r   r   r      s   
&
,
r   )numpyr   r=   Zpandasr   r   Zpandas._testingZ_testingr   Zpandas.core.reshape.utilr   r   r   r   r   r   <module>   s
   