
    bMh                       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rddlZ ej        ddg          d             Zej        d             Zej        d             Zej        d             Zej        d             Zej        d             Z  G d dej!                  Z" G 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D2D)paramsc                ,    t          | j                  S )Nfreq)r	   param)requests    b/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pandas/tests/extension/test_period.pydtyper   (   s    GM****    c                J    t          t          j        dd          |           S )Ni  i  r   )r   nparanger   s    r   datar   -   s!    ryt,,E::::r   c                (    t          g d|           S )N)      r   r
   r   s    r   data_for_sortingr!   2   s    )))7777r   c                2    t          t          dg|           S )Nr    r   r   r   r   s    r   data_missingr$   7   s    d|51111r   c                4    t          dt          dg|           S )Nr   r    r   r#   r   s    r   data_missing_for_sortingr&   <   s    dD)7777r   c           
     N    d}t           }d}d}t          ||||||||g|           S )Nr   r    r   r   )r   r   )r   BNAACs        r   data_for_groupingr,   A   s:    A	BAA1b"aAq1????r   c                       e Zd Z fdZddZddZd fdZej        	                    dddg           fd            Z
ej        	                    dddg          d             Z xZS )TestPeriodArrayc                V    |dv rd S t                                          |||          S )N)__sub____rsub__)super_get_expected_exception)selfop_nameobjother	__class__s       r   r3   z'TestPeriodArray._get_expected_exceptionK   s0    ---4ww..wUCCCr   r5   strreturnboolc                
    |dv S )N)cummincummax )r4   serr5   s      r   _supports_accumulationz&TestPeriodArray._supports_accumulationP   s    ...r   c                
    |dv S )N)minmaxmedianr?   )r4   r6   r5   s      r   _supports_reductionz#TestPeriodArray._supports_reductionS   s    222r   r@   	pd.Seriesskipnac                |   |dk    rt          ||          }|                    d          }t          ||          } ||          } ||          }|j        j        }	t	          j        t          |          |	          }t          j        ||           d S t                      
                    |||          S )NrE   int64)rH   r   )getattrastyper   r   r   _from_ordinalinttmassert_almost_equalr2   check_reduce)r4   r@   r5   rH   res_opaltexp_opresultexpectedr   r8   s             r   rQ   zTestPeriodArray.check_reduceV   s    hS'**F**W%%CS'**FV6***FvV,,,H 9>D+CMMEEEH"6844444 77''Wf===r   periods   c                &   t                      r_t          rXt          j        t          d          5  t                                          ||           d d d            d S # 1 swxY w Y   d S t                                          ||           d S )NF)check_stacklevel)r   r   rO   assert_produces_warningRuntimeWarningr2   	test_diff)r4   r   rW   r8   s      r   r^   zTestPeriodArray.test_diffh   s       	-%7 	-+NUSSS 1 1!!$0001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 GGdG,,,,,s   #A""A&)A&	na_actionNignorec                `    |                     d |          }t          j        ||           d S )Nc                    | S )Nr?   )xs    r   <lambda>z*TestPeriodArray.test_map.<locals>.<lambda>r   s    A r   )r_   )maprO   assert_extension_array_equal)r4   r   r_   rU   s       r   test_mapzTestPeriodArray.test_mapp   s2    ++;;
'55555r   )r5   r9   r:   r;   )r@   rG   r5   r9   rH   r;   )__name__
__module____qualname__r3   rA   rF   rQ   pytestmarkparametrizer^   rg   __classcell__)r8   s   @r   r.   r.   J   s        D D D D D
/ / / /3 3 3 3> > > > > >$ [YB00- - - - 10- [[4*:;;6 6 <;6 6 6 6 6r   r.   c                      e Zd ZdS )Test2DCompatN)rh   ri   rj   r?   r   r   rp   rp   v   s        Dr   rp   )%__doc__
__future__r   typingr   numpyr   rk   pandas._libsr   r   pandas.compatr   pandas.compat.numpyr   pandas.core.dtypes.dtypesr	   pandas._testing_testingrO   pandas.core.arraysr   pandas.tests.extensionr   pandaspdfixturer   r   r!   r$   r&   r,   ExtensionTestsr.   NDArrayBacked2DTestsrp   r?   r   r   <module>r      s    # " " " " "                         . - - - - - 2 2 2 2 2 2 1 1 1 1 1 1       * * * * * * ' ' ' ' ' '  T{###+ + $#+ ; ; ; 8 8 8 2 2 2 8 8 8 @ @ @)6 )6 )6 )6 )6d) )6 )6 )6X	 	 	 	 	4, 	 	 	 	 	r   