3
®yb„  ã               @   s8   d Z ddlZddlmZmZ ddljZG dd„ dƒZ	dS )z[
Tests for DataFrame cumulative operations

See also
--------
tests.series.test_cumulative
é    N)Ú	DataFrameÚSeriesc               @   s<   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )ÚTestDataFrameCumulativeOpsc             C   s0   t tjdƒjddƒtdƒtdƒd�}|jƒ }d S )Né   é   é   )ÚindexÚcolumns)r   ÚnpÚarangeZreshapeÚrangeÚcumsum)ÚselfÚdmÚresult© r   úF/tmp/pip-install-4cy230dp/pandas/pandas/tests/frame/test_cumulative.pyÚtest_cumsum_corner   s    $z-TestDataFrameCumulativeOps.test_cumsum_cornerc             C   sÐ   t j|jdd…df< t j|jdd…df< t j|jdd …df< |jƒ }|jtjƒ}tj||ƒ |jdd�}|jtjdd�}tj||ƒ tdt j	d	ƒit j	d	ƒd
�}|jƒ  |jdd�}t j
|ƒt j
|ƒksÌt‚d S )Nr   é
   r   é   é   é   )ÚaxisÚAr   )r   )r
   ÚnanÚilocr   Úapplyr   ÚtmÚassert_frame_equalr   r   ÚshapeÚAssertionError)r   Údatetime_framer   ÚexpectedÚdfZ	cumsum_xsr   r   r   Útest_cumsum   s    z&TestDataFrameCumulativeOps.test_cumsumc             C   sö   t j|jdd…df< t j|jdd…df< t j|jdd …df< |jƒ }|jtjƒ}tj||ƒ |jdd�}|jtjdd�}tj||ƒ |jdd�}t j|ƒt j|ƒks¨t	‚|j
dƒjtƒ}|jdƒ |jdƒ |j
dƒjt jƒ}|jdƒ |jdƒ d S )Nr   r   r   r   r   r   )r   )r
   r   r   Úcumprodr   r   r   r   r   r    ZfillnaZastypeÚintZint32)r   r!   r%   r"   Z
cumprod_xsr#   r   r   r   Útest_cumprod/   s"    


z'TestDataFrameCumulativeOps.test_cumprodc             C   sÐ   t j|jdd…df< t j|jdd…df< t j|jdd …df< |jƒ }|jtjƒ}tj||ƒ |jdd�}|jtjdd�}tj||ƒ tdt j	d	ƒit j	d	ƒd
�}|jƒ  |jdd�}t j
|ƒt j
|ƒksÌt‚d S )Nr   r   r   r   r   r   )r   r   r   )r   )r
   r   r   Úcumminr   r   r   r   r   r   r   r    )r   r!   r(   r"   r#   Z	cummin_xsr   r   r   Útest_cumminL   s    z&TestDataFrameCumulativeOps.test_cumminc             C   sÐ   t j|jdd…df< t j|jdd…df< t j|jdd …df< |jƒ }|jtjƒ}tj||ƒ |jdd�}|jtjdd�}tj||ƒ tdt j	d	ƒit j	d	ƒd
�}|jƒ  |jdd�}t j
|ƒt j
|ƒksÌt‚d S )Nr   r   r   r   r   r   )r   r   r   )r   )r
   r   r   Úcummaxr   r   r   r   r   r   r   r    )r   r!   r*   r"   r#   Z	cummax_xsr   r   r   Útest_cummaxc   s    z&TestDataFrameCumulativeOps.test_cummaxc             C   sr   t dddgdddgdddgdœƒ}|jƒ }t tdddgtjd	�tdddgtjd	�|d
 jƒ dœƒ}tj||ƒ d S )Nr   r   é   g      @TF)r   ÚBÚCé   )Zdtyper.   )r   r   r   r
   Zint64Zfloat64r   r   )r   r#   r   r"   r   r   r   Ú#test_cumulative_ops_preserve_dtypesz   s    "z>TestDataFrameCumulativeOps.test_cumulative_ops_preserve_dtypesN)	Ú__name__Ú
__module__Ú__qualname__r   r$   r'   r)   r+   r0   r   r   r   r   r      s   r   )
Ú__doc__Znumpyr
   Zpandasr   r   Zpandas._testingZ_testingr   r   r   r   r   r   Ú<module>   s   
