a
    Pf                     @  s  d Z ddlmZ ddlmZ ddlZddlZddlm	Z	m
Z
 ddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ erddlZejddgddd Zejdd Zejdd Zejdd Zejdd Zejdd Z G dd dej!Z"G dd dej#Z$dS )aj  
This file contains a minimal set of tests for compliance with the extension
array interface test suite, and should contain no other tests.
The test suite for the full functionality of the array is located in
`pandas/tests/arrays/`.

The tests in this file are inherited from the BaseExtensionTests, and only
minimal tweaks should be applied to get the tests passing (by overwriting a
parent method).

Additional tests should either be added to one of the BaseExtensionTests
classes (if they are relevant for the extension interface for all dtypes), or
be added to the array-specific tests in `pandas/tests/arrays/`.

    )annotations)TYPE_CHECKINGN)PeriodiNaT)is_platform_windows)np_version_gte1p24)PeriodDtypePeriodArray)baseDZ2D)paramsc                 C  s   t | jdS )Nfreq)r   param)request r   [/var/www/ai-form-bot/venv/lib/python3.9/site-packages/pandas/tests/extension/test_period.pydtype(   s    r   c                 C  s   t tdd| dS )Ni  i  r   )r
   npZaranger   r   r   r   data-   s    r   c                 C  s   t g d| dS )N)      r   r	   r   r   r   r   data_for_sorting2   s    r   c                 C  s   t tdg| dS )Nr   r   r
   r   r   r   r   r   data_missing7   s    r   c                 C  s   t dtdg| dS )Nr   r   r   r   r   r   r   r   data_missing_for_sorting<   s    r   c              	   C  s,   d}t }d}d}t||||||||g| dS )Nr   r   r   r   )r   r
   )r   BZNAACr   r   r   data_for_groupingA   s
    r"   c                      s   e Zd Z fddZdddddZddddd	Zd
ddd fddZej	dddg fddZ
ej	dddgdd Z  ZS )TestPeriodArrayc                   s   |dv rd S t  |||S )N)__sub____rsub__)super_get_expected_exception)selfop_nameobjother	__class__r   r   r'   K   s    z'TestPeriodArray._get_expected_exceptionstrbool)r)   returnc                 C  s   |dv S )N)ZcumminZcummaxr   )r(   serr)   r   r   r   _supports_accumulationP   s    z&TestPeriodArray._supports_accumulationc                 C  s   |dv S )N)minmaxmedianr   )r(   r*   r)   r   r   r   _supports_reductionS   s    z#TestPeriodArray._supports_reductionz	pd.Series)r1   r)   skipnac           
        sv   |dkrbt ||}|d}t ||}||d}||d}|jj}	tjt||	d}t|| nt	 
|||S d S )Nr5   Zint64)r7   r   )getattrZastyper   r   r   Z_from_ordinalinttmZassert_almost_equalr&   check_reduce)
r(   r1   r)   r7   Zres_opZaltZexp_opresultexpectedr   r,   r   r   r;   V   s    




zTestPeriodArray.check_reduceperiods   c                   sZ   t  rHtrHtjtdd t || W d    qV1 s<0    Y  nt || d S )NF)Zcheck_stacklevel)r   r   r:   Zassert_produces_warningRuntimeWarningr&   	test_diff)r(   r   r>   r,   r   r   rB   h   s    
.zTestPeriodArray.test_diff	na_actionNignorec                 C  s"   |j dd |d}t|| d S )Nc                 S  s   | S )Nr   )xr   r   r   <lambda>r       z*TestPeriodArray.test_map.<locals>.<lambda>)rC   )mapr:   Zassert_extension_array_equal)r(   r   rC   r<   r   r   r   test_mapp   s    zTestPeriodArray.test_map)__name__
__module____qualname__r'   r2   r6   r;   pytestmarkZparametrizerB   rI   __classcell__r   r   r,   r   r#   J   s   r#   c                   @  s   e Zd ZdS )Test2DCompatN)rJ   rK   rL   r   r   r   r   rP   v   s   rP   )%__doc__
__future__r   typingr   numpyr   rM   Zpandas._libsr   r   Zpandas.compatr   Zpandas.compat.numpyr   Zpandas.core.dtypes.dtypesr   Zpandas._testingZ_testingr:   Zpandas.core.arraysr
   Zpandas.tests.extensionr   ZpandaspdZfixturer   r   r   r   r   r"   ZExtensionTestsr#   ZNDArrayBacked2DTestsrP   r   r   r   r   <module>   s6   





,