U
    ¾mœdÛ  ã                   @   sH   d Z ddlZddlZddlmZmZ ddlmZmZ dd„ Z	dd„ Z
dS )	zY
Test the consistency of the groupby API, both internally and with other pandas objects.
é    N)Ú	DataFrameÚSeries)ÚDataFrameGroupByÚSeriesGroupByc           	      C   sþ  |dkr"d}| j  tjj|d�¡ |dkrDd}| j  tjj|d�¡ |dkr^tt|ƒrZt‚d S tt|ƒ}tt	|ƒ}t
t |¡jƒ}|dkr’dh}nt
t |¡jƒ}t
ƒ t
ƒ  }}|d	krÄd
ddh}nô|dkrÖddh}nâ|dkrædh}nÒ|dk�rdd
dh}dddh}n²|dk�r$dd
dh}ddh}n”|dk�r:dd
dh}n~|dk�rPdddh}nh|dk�rjddh}dh}nN|dk�r|dh}n<|dk�r”d
h}dh}n$|dk�r¦dh}n|dk�r¸d dh}||@ |k�sÊt‚||@ |k�sÜt‚||8 }||8 }||k�sút‚d S )!N©ÚfirstÚlastz?first and last are entirely different between frame and groupby©Úreason)ÚcumcountzDataFrame has no such methodÚngroupÚsizeÚself©ÚanyÚallÚkwargsÚ	bool_onlyÚaxis)ÚcountÚnumeric_only)Znunique©ÚmaxÚminÚskipnaÚ	min_countÚengineÚengine_kwargs©ZmeanZstdÚsumÚvar©ZmedianÚprodZsem©ZbackfillZbfillZffillÚpadÚdowncastÚinplace©ZcummaxZcumminÚargs©ZcumprodZcumsum©Z
pct_change©Zrank©ZquantileÚmethod)ÚnodeÚ
add_markerÚpytestÚmarkÚxfailÚhasattrr   ÚAssertionErrorÚgetattrr   ÚsetÚinspectÚ	signatureÚ
parameters)	ÚrequestÚgroupby_funcÚmsgZframe_methodÚ	gb_methodÚresultÚexpectedÚexclude_expectedÚexclude_result© rB   úb/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/pandas/tests/groupby/test_api_consistency.pyÚtest_frame_consistency   sb    














rD   c           	      C   sü  |dkr"d}| j  tjj|d�¡ |dkrDd}| j  tjj|d�¡ |dkr^tt|ƒrZt‚d S tt|ƒ}tt	|ƒ}t
t |¡jƒ}|dkr’dh}nt
t |¡jƒ}t
ƒ t
ƒ  }}|d	krÄd
ddh}nò|dkrÔdh}nâ|dkròdd
dh}dddh}nÄ|dk�rdd
dh}ddh}n¦|dk�r&dd
dh}n�|dk�r<dddh}nz|dk�rVddh}dh}n`|dk�rhdh}nN|dk�r€d
h}dh}n6|dk�r’dh}n$|dk�r¦dd
h}n|dk�r¶dh}||@ |k�sÈt‚||@ |k�sÚt‚||8 }||8 }||k�søt‚d S ) Nr   z@first and last are entirely different between Series and groupbyr	   )r   ZcorrwithzSeries has no such methodr   r   r   r   r   r   r   )Údiffr   r   r   r   r   r   r!   r#   r%   r&   r'   r(   r   r)   r*   r+   )ZidxminZidxmaxr,   )r.   r/   r0   r1   r2   r3   r   r4   r5   r   r6   r7   r8   r9   )	r:   r;   r<   Zseries_methodr=   r>   r?   r@   rA   rB   rB   rC   Útest_series_consistencyR   sb    














rF   )Ú__doc__r7   r0   Zpandasr   r   Zpandas.core.groupby.genericr   r   rD   rF   rB   rB   rB   rC   Ú<module>   s   ?