a
    oÝEb+  ã                   @   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   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   ú^/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/pandas/tests/reshape/test_util.pyÚtest_simple   s    z TestCartesianProduct.test_simplec                 C   sZ   t ddd�}dd„ t||gƒD ƒ\}}tg d¢ƒ}tg 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   )r   r   r   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 g d¢g}t ||ƒD ]\\}}tjg t |¡jd�}tjg t |¡jd�}t||gƒ\}}t ||¡ t ||¡ q&tg ƒ}	g }
|	|
ksœJ ‚d S )Nr   r   )ÚaÚbÚc©Údtype)Úzipr   r   Zasarrayr3   r   r   r   )r   ÚXÚYr   r   r   r   r   r   Úresultr+   r   r   r   Ú
test_empty/   s    zTestCartesianProduct.test_emptyr5   r   r   r/   r0   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©r5   )ÚpytestÚraisesÚ	TypeErrorr   )r   r5   Ú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!r9   c                 S   s   g | ]}t jd dt jd�‘qS )r   r   r2   )r   ÚarangeÚint16)r   Úir   r   r   Ú
<listcomp>M   r!   zBTestCartesianProduct.test_exceed_product_space.<locals>.<listcomp>é   i;  r2   r;   )r<   r=   Ú
ValueErrorÚranger   rA   rB   r   )r   r?   Ú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@   rI   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
   