o
    թZh!!                     @   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sJ d S )Nsecond)levelc                 S      h | ]	}| d s|qS _
startswith).0v r   T/var/www/html/lang_env/lib/python3.10/site-packages/pandas/tests/groupby/test_api.py	<setcomp>       z&test_tab_completion.<locals>.<setcomp>>B   Z	transformZcorrCidxmaxstdprodpipeZvalue_countssizecountZdescribeZtakecumcountZ	aggregatecumsum
pct_changeZaggZfillnaanyZcovZnthZplotZrollingZresampleZ	expandingZohlcmeanminheadffillcumprodtailsumZboxplotnuniquecummaxbfillindicesapplyngroupcorrwithcumminZewmfirstZskewBZdtypesidxminrankndimvarlastallAfiltergroupsZngroupsquantileZ	get_groupsemsamplediffhistshiftmedianmax)groupbydir) multiindex_dataframe_random_datagrpresultsexpectedr   r   r   test_tab_completion   s   DrI   c                 C   s   |  | jd d df }dd t|D t| j }t|}|t8 }|t8 }|t8 }tt@ r0J tt@ r6J tt@ r<J |rHd| d}t|ttB tB }||kr^d||  d}t|d S )Nr   c                 S   r   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
)	rC   ZilocrD   setcolumnsr   r   r   AssertionError)rE   rF   namesZ	new_namesmsgZall_categorizedr   r   r   test_all_methods_categorizede   s2   rO   c                 C   s  | dv rd}t j|d | dv rtt| rJ d S tt| }tt| }tt|j	}| dkr3dh}ntt|j	}t t }}| dv rKh d}nl| d	v rTd
dh}nc| dv r\dh}n[| dv rih d}h d}nN| dv rvh d}ddh}nA| dv rh d}n8| dv rh d}n/| dv rddh}d
h}n#| dv rdh}n| dv rdh}dh}n| dv rd
h}n| dv rddh}||@ |ksJ ||@ |ksJ ||8 }||8 }||ksJ d S )Nr0   r6   z?first and last are entirely different between frame and groupby)reason)r   r-   r   selfr    r7   >   	bool_onlyaxiskwargs)r   numeric_onlyrU   )r(   rB   r"   >   rU   skipnarV      Z	min_countengineengine_kwargsr!   r   r'   r5   r[   r\   rA   r   r<   Zbackfillr*   r$   pad   ZdowncastrU   ZinplaceZ
limit_arear)   r/   rY   argsr%   r   r   rV   r3   r;   method)
pytestskiphasattrr   getattrr   rJ   inspect	signature
parameters)groupby_funcrN   Zframe_method	gb_methodresultrH   exclude_expectedexclude_resultr   r   r   test_frame_consistency   s\   







ru   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r0dh}ntt|j	}t t }}|dv rHh d}nk|dv rPd	h}nc|d
v r]h d}h d}nV|dv rjh d}ddh}nI|dv rsh d}n@|dv r|h d}n7|dv rddh}dh}n+|dv rdh}n#|dv rdh}d	h}n|dv rdh}n|dv rddh}n|dv rdh}||@ |ksJ ||@ |ksJ ||8 }||8 }||ksJ d S )NrP   z@first and last are entirely different between Series and groupby)r   r.   r-   r   rR   rS   >   rT   rU   rV   )r>   rU   rX   >   rU   rY   rV   rZ   r]   r[   r\   r^   r_   ra   rb   rY   rc   rW   rd   re   rV   rf   )r2   r   rg   )
ri   rj   rk   r   rl   r   rJ   rm   rn   ro   )requestrp   Zseries_methodrq   rr   rH   rs   rt   r   r   r   test_series_consistency   sZ   








rw   )__doc__rm   ri   Zpandasr   r   Zpandas.core.groupby.baser   r   r   Zpandas.core.groupby.genericr   r   rI   rO   ru   rw   r   r   r   r   <module>   s    J0<