o
    $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sJ d S )Nsecond)levelc                 S      h | ]	}| d s|qS _
startswith).0v r   ^/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/pandas/tests/groupby/test_api.py	<setcomp>       z&test_tab_completion.<locals>.<setcomp>>B   Z	get_groupZrollingapplyZdtypesfiltercummaxdiffZ	aggregatepipesizeZaggZngroupsZohlcZvalue_countsquantilebfillndimindicesminhiststdZresampleZ	expandingBngroupZboxplotgroupsnuniquecumprodC	transform
pct_changemeanidxminffillprodZskewvarAZcovanyshiftmedianheadidxmaxZewmlastmaxcounttailZfillnacorrwithsemrankZcorrcumcountcumminZdescribeZnthcumsumZtakeallsamplesumfirstZplot)groupbydir) multiindex_dataframe_random_datagrpresultsexpectedr   r   r   test_tab_completion   s   DrJ   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
)	rD   ZilocrE   setcolumnsr   r   r   AssertionError)rF   rG   namesZ	new_namesmsgZall_categorizedr   r   r   test_all_methods_categorizede   s2   rP   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rC   r6   z?first and last are entirely different between frame and groupby)reason)r=   r$   r   selfr1   r@   >   kwargs	bool_onlyaxis)r8   numeric_onlyrW   )r&   r7   r    >   rU   skipnarW      engineengine_kwargsZ	min_countr+   r"   rB   r/   r\   r]   r3   r.   r;   Zbackfillr   r-   pad   ZinplaceZ
limit_areaZdowncastrW   r   r>   rZ   argsr'   r?   r*   rU   r<   r   method)
pytestskiphasattrr   getattrr   rK   inspect	signature
parameters)groupby_funcrO   Zframe_method	gb_methodresultrI   exclude_expectedexclude_resultr   r   r   test_frame_consistency   s\   







rv   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 )NrQ   z@first and last are entirely different between Series and groupby)r=   r:   r$   r   rS   rT   >   rU   rV   rW   )r   rW   rY   >   rU   rZ   rW   r[   r^   r\   r]   r_   r`   rb   rc   rZ   rd   rX   re   rf   rU   rg   )r,   r5   rh   )
rj   rk   rl   r   rm   r   rK   rn   ro   rp   )requestrq   Zseries_methodrr   rs   rI   rt   ru   r   r   r   test_series_consistency   sZ   








rx   )__doc__rn   rj   Zpandasr   r   Zpandas.core.groupby.baser   r   r   Zpandas.core.groupby.genericr   r   rJ   rP   rv   rx   r   r   r   r   <module>   s    J0<