
    bMh                        d Z ddlZddlZddlmZ ddlZddlm	Z
 ddlmZ ddlmZ  ej        dg          d             Zej        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/`.

    N)DatetimeTZDtype)DatetimeArray)basez
US/Central)paramsc                 .    t          d| j                  S )Nns)unittz)r   param)requests    d/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pandas/tests/extension/test_datetime.pydtyper      s    7777    c                 f    t          j        t          j        dd| j                  |           }|S )N2000d   )periodsr
   r   )r   _from_sequencepd
date_ranger
   )r   datas     r   r   r       s8    '
fceh777u  D Kr   c                 Z    t          j        t          j        ddgd          |           S )NNaT
2000-01-01datetime64[ns]r   )r   r   nparrayr   s    r   data_missingr   (   s6    '
%&.>???u   r   c                     t          j        d          }t          j        d          }t          j        d          }t          j        t	          j        |||gd          |           S )Nr   
2000-01-02
2000-01-03r   r   r   	Timestampr   r   r   r   )r   abcs       r   data_for_sortingr(   /   sd    
\""A
\""A
\""A'
!Q"23335   r   c                     t          j        d          }t          j        d          }t          j        t	          j        |d|gd          |           S )Nr   r!   r   r   r   r#   )r   r%   r&   s      r   data_missing_for_sortingr*   9   sU    
\""A
\""A'
!UA&6777u   r   c                     t          j        d          }t          j        d          }t          j        d          }d}t          j        t	          j        ||||||||gd          |           S )z_
    Expected to be like [B, B, NA, NA, A, A, B, C]

    Where A < B < C and NA is missing
    r   r!   r"   r   r   r   r#   )r   r%   r&   r'   nas        r   data_for_groupingr-   B   sv     	\""A
\""A
\""A	B'
!QB1a+3CDDDE   r   c                      d } | S )Nc                 &    | t           j        u o| |u S N)r   r   )r%   r&   s     r   cmpzna_cmp.<locals>.cmpT   s    BF{%qAv%r    )r1   s    r   na_cmpr3   R   s    & & & Jr   c                       e Zd Z fdZdedefdZdedefdZej	        
                    dddg           fd	            Z fd
Zej	        
                    dddg          d             Zdej        dedef fdZ xZS )TestDatetimeArrayc                 V    |dv rd S t                                          |||          S )N)__sub____rsub__)super_get_expected_exception)selfop_nameobjother	__class__s       r   r:   z)TestDatetimeArray._get_expected_exception\   s0    ---4ww..wUCCCr   r<   returnc                 
    |dv S )N)cummincummaxr2   )r;   serr<   s      r   _supports_accumulationz(TestDatetimeArray._supports_accumulationa   s    ...r   c                 
    |dv S )N)minmaxmedianmeanstdanyallr2   )r;   r=   r<   s      r   _supports_reductionz%TestDatetimeArray._supports_reductiond   s    OOOr   skipnaTFc                     |}d| d}t          j        t          |d          5  t                                          |||           d d d            d S # 1 swxY w Y   d S )N'z8' with datetime64 dtypes is deprecated and will raise inF)matchcheck_stacklevel)tmassert_produces_warningFutureWarningr9   test_reduce_series_boolean)r;   r   all_boolean_reductionsrO   methmsgr?   s         r   rW   z,TestDatetimeArray.test_reduce_series_booleang   s    %P$PPP'u
 
 
 	U 	U GG..t5KVTTT	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	Us   $AAAc                 t    |                     d           }t                                          |           d S r0   )
_with_freqr9   test_series_constructor)r;   r   r?   s     r   r]   z)TestDatetimeArray.test_series_constructorp   s2    t$$''-----r   	na_actionNignorec                 `    |                     d |          }t          j        ||           d S )Nc                     | S r0   r2   )xs    r   <lambda>z,TestDatetimeArray.test_map.<locals>.<lambda>w   s    A r   )r^   )maprT   assert_extension_array_equal)r;   r   r^   results       r   test_mapzTestDatetimeArray.test_mapu   s2    ++;;
'55555r   rD   c                    |dv r|                     d          }t          ||          }t          ||          } ||          } ||          }|dv r#|j        j        }	t	          j        ||	          }nt	          j        |          }t          j        ||           d S t                      
                    |||          S )N)rI   rJ   rK   int64)rO   )rJ   rI   )r
   )astypegetattrr   r
   r   r$   	TimedeltarT   assert_almost_equalr9   check_reduce)r;   rD   r<   rO   altres_opexp_oprf   expectedr
   r?   s             r   rn   zTestDatetimeArray.check_reducez   s    ///**W%%CS'**FS'**FV6***FvV,,,H,,, Y\<R888<11"6844444 77''Wf===r   )__name__
__module____qualname__r:   strboolrE   rN   pytestmarkparametrizerW   r]   rg   r   Seriesrn   __classcell__)r?   s   @r   r5   r5   [   sI       D D D D D
/3 /4 / / / /P P P P P P [Xe}55U U U U 65U. . . . .
 [[4*:;;6 6 <;6>	 >C > > > > > > > > > > >r   r5   c                       e Zd ZdS )Test2DCompatN)rs   rt   ru   r2   r   r   r~   r~      s        Dr   r~   )__doc__numpyr   rx   pandas.core.dtypes.dtypesr   pandasr   pandas._testing_testingrT   pandas.core.arraysr   pandas.tests.extensionr   fixturer   r   r   r(   r*   r-   r3   ExtensionTestsr5   NDArrayBacked2DTestsr~   r2   r   r   <module>r      s         5 5 5 5 5 5           , , , , , , ' ' ' ' ' ' ~&&&8 8 '&8                  1> 1> 1> 1> 1>+ 1> 1> 1>h	 	 	 	 	4, 	 	 	 	 	r   