U
    +if+                     @   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                   @   sz   e Zd Zdd Zdd Zdd Z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   sj   t dddg }}t||g\}}tddddddg}tddddddg}t|| t|| d S )NABC      ABC)listr   nparraytmassert_numpy_array_equal)selfxyresult1result2	expected1	expected2 r   Q/home/mars/bis/venv/lib/python3.8/site-packages/pandas/tests/reshape/test_util.pytest_simple   s    z TestCartesianProduct.test_simplec                 C   sb   t ddd}dd t||gD \}}tddddg}tddddg}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>   s     z:TestCartesianProduct.test_datetimeindex.<locals>.<genexpr>r   )r   r   r   r   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_categoricalc                 C   s   g ddgg g}g g dddgg}t ||D ]\\}}tjg t|jd}tjg t|jd}t||g\}}t|| t|| q(tg }	g }
|	|
kstd S )Nr   r   abcdtype)	zipr   r   Zasarrayr2   r   r   r   AssertionError)r   XYr   r   r   r   r   r   resultr*   r   r   r   
test_empty/   s    zTestCartesianProduct.test_emptyr5   r   r   r.   r/   c              	   C   s,   d}t jt|d t|d W 5 Q R X d S )Nz'Input must be a list-like of list-likesmatchr5   )pytestraises	TypeErrorr   )r   r5   msgr   r   r   test_invalid_input?   s    z'TestCartesianProduct.test_invalid_inputc              	   C   sP   d}t jt|d4 dd tdD tjdtjdg }t|d W 5 Q R X d S )	Nz+Product space too large to allocate arrays!r9   c                 S   s   g | ]}t jd dt jdqS )r   r   r1   )r   arangeint16)r   ir   r   r   
<listcomp>M   s     zBTestCartesianProduct.test_exceed_product_space.<locals>.<listcomp>   i;  r1   r;   )r<   r=   
ValueErrorranger   rA   rB   r   )r   r?   Zdimsr   r   r   test_exceed_product_spaceH   s    z.TestCartesianProduct.test_exceed_product_spaceN)__name__
__module____qualname__r   r"   r+   r-   r8   r<   markZparametrizer@   rH   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
   