U
    sVc                     @   s   d dl mZ d dlZd dlZd dlZd dlm  m  m	Z
 d dlmZ d dlmZ dd Ze Zejed ed dd	d
 Zdd Zdd ZdS )    )partialN)Seriesc                  C   s   dt jfdt jfgdd dD  dt jfdt jfdt jfd	t jfd
t jfg dd dD  dd dD  } tt	|  }|d |d dS )Nroll_sum	roll_meanc                 S   s&   g | ]}d | dt tj|dfqS )z	roll_var())ddof)r   window_aggregationsZroll_var).0r    r
   P/tmp/pip-unpacked-wheel-xj8nt62q/pandas/tests/window/test_cython_aggregations.py
<listcomp>   s   z-_get_rolling_aggregations.<locals>.<listcomp>)r      	roll_skew	roll_kurtroll_median_croll_maxroll_minc              	   S   s:   g | ]2}t jD ]&}d | d| dtt j||dfqqS )zroll_quantile(,r   )quantileinterpolation)r   Zinterpolation_typesr   Zroll_quantile)r	   r   r   r
   r
   r   r   "   s   	 )g-C6?g      ?gH.?c                 S   sP   g | ]H}t j D ]8}d D ].}d| d| d| dtt j|||dfqqqS )TFz
roll_rank(r   r   )
percentilemethod	ascending)r   Zrolling_rank_tiebreakerskeysr   Z	roll_rank)r	   r   r   r   r
   r
   r   r   .   s   
  r   r   r   )idsparams)
r   r   r   r   r   r   r   r   listzip)Znamed_roll_aggsZunzippedr
   r
   r   _get_rolling_aggregations   s2    		
,r   r   r   )r   r   c                 C   s   | j S )z/Make a rolling aggregation function as fixture.)param)requestr
   r
   r   rolling_aggregationE   s    r"   c                 C   s   ddddddgf\}}}}}t jdd| t jd}t j|||t jd}|| }t j|t jd}	t| |||	 ||	 |}
t| |||||	 }t||
 d S )Nr   r               Zdtype)	nparangefloat64int64arrayint32r   tmassert_equal)r"   minpstepwidthsizeZ	selectionvaluesendstartZselarrresultexpectedr
   r
   r   -test_rolling_aggregation_boundary_consistencyM   s    r9   c                    s>  d\}}d| d }t jd|d t jd}tjj|||d < t j||d < tjj||d |d < t jd|| gt j	dt j||gt j	d t j fdd	t
tD t jd}t| | |}t j|| t jd}t jdt| |t j	d}|| }	t| |||	|}
t |
j s.td
t|
| d S )N)r      r%   r:   r   r'   r#   r   c                    s(   g | ] }t |  | D ]}|qqS r
   )range)r	   ijr5   r6   r
   r   r   d   s       zAtest_rolling_aggregation_with_unused_elements.<locals>.<listcomp>z"Not all expected values are finite)r(   r)   r*   sys
float_infominnanmaxr,   r+   r;   lenr-   r   isfiniter4   allAssertionErrorr.   r/   )r"   r0   r2   r3   r4   locr7   Zcompact_valuesZcompact_startZcompact_endr8   r
   r>   r   -test_rolling_aggregation_with_unused_elementsY   s*    rI   )	functoolsr   r?   Znumpyr(   ZpytestZ pandas._libs.window.aggregationsZ_libsZwindowZaggregationsr   Zpandasr   Zpandas._testingZ_testingr.   r   Z_rolling_aggregationsZfixturer"   r9   rI   r
   r
   r
   r   <module>   s   5 
