a
    +ñ»j!!  ã                   @   sl   d Z ddlZddlZddlmZmZ ddlmZmZm	Z	 ddl
mZmZ dd„ Zdd	„ Zd
d„ Zdd„ ZdS )zð
Tests of the groupby API, including internal consistency and with other pandas objects.

Tests in this file should only check the existence, names, and arguments of groupby
methods. It should not test the results of any groupby operation.
é    N)Ú	DataFrameÚSeries)Úgroupby_other_methodsÚreduction_kernelsÚtransformation_kernels)ÚDataFrameGroupByÚSeriesGroupByc                 C   s6   | j dd�}dd„ t|ƒD ƒ}h d£}||ks2J ‚d S )NÚsecond)Úlevelc                 S   s   h | ]}|  d ¡s|’qS ©Ú_©Ú
startswith)Ú.0Úv© r   úCE:\soccer\ml_env\Lib\site-packages\pandas/tests/groupby/test_api.pyÚ	<setcomp>   ó    z&test_tab_completion.<locals>.<setcomp>>B   ÚshiftÚheadÚallÚfilterÚhistZaggZtakeÚ
pct_changeÚdiffZrollingÚidxmaxZ	get_groupZcorrÚbfillÚtailÚindicesZnthÚapplyZvalue_countsZewmÚndimÚnuniqueÚcumminZcovZ	expandingÚcummaxÚBZ	transformZngroupsÚmeanÚgroupsÚquantileÚngroupÚpipeÚprodÚcumprodÚstdÚmaxÚminÚsemZskewZboxplotÚcountÚfirstZdtypesZohlcÚvarÚcumcountÚcorrwithÚsizeZfillnaÚanyÚlastÚsumZdescribeÚAÚCÚrankÚidxminÚmedianÚcumsumÚffillÚsampleZplotZ	aggregateZresample)ÚgroupbyÚdir)Ú multiindex_dataframe_random_dataÚgrpÚresultsÚexpectedr   r   r   Útest_tab_completion   s    DrH   c                 C   sÀ   |   | jd d …df ¡}dd„ t|ƒD ƒt| jƒ }t|ƒ}|t8 }|t8 }|t8 }tt@ r`J ‚tt@ rlJ ‚tt@ rxJ ‚|r�d|› d�}t|ƒ‚ttB tB }||kr¼d|| › d�}t|ƒ‚d S )Nr   c                 S   s   h | ]}|  d ¡s|’qS r   r   )r   r   r   r   r   r   i   r   z/test_all_methods_categorized.<locals>.<setcomp>z?
There are uncategorized methods defined on the Grouper class:
aG  .

Was a new method recently added?

Every public method On Grouper must appear in exactly one the
following three lists defined in pandas.core.groupby.base:
- `reduction_kernels`
- `transformation_kernels`
- `groupby_other_methods`
see the comments in pandas/core/groupby/base.py for guidance on
how to fix this test.
        zI
Some methods which are supposed to be on the Grouper class
are missing:
z‡.

They're still defined in one of the lists that live in pandas/core/groupby/base.py.
If you removed a method, you should update them
)	rB   ZilocrC   ÚsetÚcolumnsr   r   r   ÚAssertionError)rD   rE   ÚnamesZ	new_namesÚmsgZall_categorizedr   r   r   Útest_all_methods_categorizede   s0    ÿÿþýrN   c                 C   sÂ  | dv rd}t j|d� | dv r2tt| ƒr.J ‚d S tt| ƒ}tt| ƒ}tt |¡j	ƒ}| dkrfdh}ntt |¡j	ƒ}tƒ tƒ  }}| dv r–h d£}næ| d	v r¨d
dh}nÔ| dv r¸dh}nÄ| dv rÒh d£}h d£}nª| dv rìh d£}ddh}n�| dv �r h d£}n|| dv �rh d£}nh| dv �r.ddh}d
h}nN| dv �r@dh}n<| dv �rXdh}dh}n$| dv �rjd
h}n| dv �r|ddh}||@ |k�sŽJ ‚||@ |k�s J ‚||8 }||8 }||k�s¾J ‚d S )N©r2   r8   z?first and last are entirely different between frame and groupby)Úreason)r4   r)   r6   Úself©r7   r   >   ÚaxisÚ	bool_onlyÚkwargs)r1   Únumeric_onlyrS   )r"   ©r.   r/   >   ÚskipnarS   rU   ¾   Úengine_kwargsÚengineZ	min_count©r&   r-   r9   r3   r[   rZ   ©r>   r+   r0   ©Zbackfillr   r@   Úpad¾   Z
limit_arearS   ZdowncastZinplace©r$   r#   rX   Úargs©r,   r?   ©r   rU   ©r<   ©r(   Úmethod)
ÚpytestÚskipÚhasattrr   Úgetattrr   rI   ÚinspectÚ	signatureÚ
parameters)Úgroupby_funcrM   Zframe_methodÚ	gb_methodÚresultrG   Úexclude_expectedÚexclude_resultr   r   r   Útest_frame_consistency•   s\    














rt   c                 C   s¸  |dv rt  d¡ |dv r,tt|ƒr(J ‚d S tt|ƒ}tt|ƒ}tt |¡j	ƒ}|dkr`dh}ntt |¡j	ƒ}tƒ tƒ  }}|dv r�h d£}nâ|dv r d	h}nÒ|d
v rºh d£}h d£}n¸|dv rÔh d£}ddh}nž|dv ræh d£}nŒ|dv røh d£}nz|dv �rddh}dh}n`|dv �r$dh}nN|dv �r<dh}d	h}n6|dv �rNdh}n$|dv �rbddh}n|dv �rrdh}||@ |k�s„J ‚||@ |k�s–J ‚||8 }||8 }||k�s´J ‚d S )NrO   z@first and last are entirely different between Series and groupby)r4   r5   r)   r6   rQ   rR   >   rS   rT   rU   )r   rS   rW   >   rX   rS   rU   rY   r\   r[   rZ   r]   r^   r`   ra   rX   rb   rV   rc   rd   rU   re   )r=   r   rf   )
rh   ri   rj   r   rk   r   rI   rl   rm   rn   )Úrequestro   Zseries_methodrp   rq   rG   rr   rs   r   r   r   Útest_series_consistencyÑ   sZ    














rv   )Ú__doc__rl   rh   Zpandasr   r   Zpandas.core.groupby.baser   r   r   Zpandas.core.groupby.genericr   r   rH   rN   rt   rv   r   r   r   r   Ú<module>   s   J0<