a
    DBì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   ú\/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/pandas/tests/groupby/test_api.pyÚ	<setcomp>   ó    z&test_tab_completion.<locals>.<setcomp>>B   ÚsizeZdescribeÚstdÚAÚheadÚ
pct_changeZplotÚmedianZtakeZngroupsÚcumsumÚndimÚsumÚquantileÚgroupsZskewZrollingÚmeanZohlcÚshiftÚidxmaxÚcountÚcumcountZcorrZaggÚapplyÚfilterZ	expandingÚpipeÚhistÚvarÚsampleZboxplotÚcorrwithÚdiffÚmaxZ	transformZ	get_groupÚbfillZresampleÚcumminÚindicesÚanyÚminZdtypesÚprodÚsemÚBÚffillÚcumprodZnthÚlastZfillnaZcovÚidxminZ	aggregateÚCÚtailZewmZvalue_countsÚrankÚnuniqueÚngroupÚcummaxÚfirstÚall)Ú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©r@   r8   z?first and last are entirely different between frame and groupby)Úreason)r$   r>   r   Úself©r1   rA   >   Ú	bool_onlyÚkwargsÚaxis)r#   Únumeric_onlyrU   )r=   ©r-   r2   >   rU   rT   Úskipna¾   Z	min_countÚengineÚengine_kwargs©r    r   r   r)   rZ   r[   ©r   r3   r4   ©Zbackfillr.   r6   Úpad¾   ZdowncastZ
limit_arearU   Zinplace©r?   r/   rX   Úargs©r7   r   ©r   rT   ©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)r$   r+   r>   r   rQ   rR   >   rS   rT   rU   )r,   rU   rW   >   rU   rT   rX   rY   r\   rZ   r[   r]   r^   r`   ra   rX   rb   rV   rc   rd   rT   re   )r9   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<