
    .iF                        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        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j2                        Zy)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)basec                      t        dd      S )Nnsz
US/Central)unittzr        b/var/www/app/trading-bot/venv/lib/python3.12/site-packages/pandas/tests/extension/test_datetime.pydtyper      s    66r   c                 t    t        j                  t        j                  dd| j                        |       }|S )N2000
   )periodsr
   r   )r   _from_sequencepd
date_ranger
   )r   datas     r   r   r   !   s/    ''
fbUXX6eD Kr   c                 ^    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   )   s+    ''
%&.>?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'   0   sV    
\"A
\"A
\"A''
!Q"2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)   :   sH    
\"A
\"A''
!UA&6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,   C   sh     	\"A
\"A
\"A	B''
!QB1a+3CDE r   c                      d } | S )Nc                 2    | t         j                  u xr | |u S N)r   r   )r$   r%   s     r   cmpzna_cmp.<locals>.cmpU   s    BFF{%qAv%r   r   )r0   s    r   na_cmpr1   S   s    & Jr   c                       e Zd Z fdZdedefdZdedefdZdedefdZe	j                  j                  ddd	g       fd
       Z fdZe	j                  j                  dddg      d        Zdej                   dedef fdZ xZS )TestDatetimeArrayc                 0    |dv ry t         |   |||      S )N)__sub____rsub__)super_get_expected_exception)selfop_nameobjother	__class__s       r   r8   z)TestDatetimeArray._get_expected_exception]   s#    --w.wUCCr   r:   skipnac                 &    |dk(  ry|j                   S )Nstdztimedelta64[ns]r   )r9   arrr:   r>   s       r   _get_expected_reduction_dtypez/TestDatetimeArray._get_expected_reduction_dtypeb   s    e$yyr   returnc                 
    |dv S )N)cummincummaxr   )r9   serr:   s      r   _supports_accumulationz(TestDatetimeArray._supports_accumulationg   s    ...r   c                 
    |dv S )N)minmaxmedianmeanr@   anyallr   )r9   r;   r:   s      r   _supports_reductionz%TestDatetimeArray._supports_reductionj   s    OOOr   TFc                     |}d| d}t        j                  t        |      5  t        |   |||       d d d        y # 1 sw Y   y xY w)Nz,datetime64 type does not support operation '')match)pytestraises	TypeErrorr7   test_reduce_series_boolean)r9   r   all_boolean_reductionsr>   methmsgr=   s         r   rW   z,TestDatetimeArray.test_reduce_series_booleanm   sO    %<TF!D]]9C0 	UG.t5KVT	U 	U 	Us   A  A	c                 F    |j                  d       }t        | 	  |       y r/   )
_with_freqr7   test_series_constructor)r9   r   r=   s     r   r]   z)TestDatetimeArray.test_series_constructort   s    t$'-r   	na_actionNignorec                 X    |j                  d |      }t        j                  ||       y )Nc                     | S r/   r   )xs    r   <lambda>z,TestDatetimeArray.test_map.<locals>.<lambda>{   s    A r   )r^   )maptmassert_extension_array_equal)r9   r   r^   results       r   test_mapzTestDatetimeArray.test_mapy   s$    +;
''5r   rG   c                 `   |dv r|j                  d      }t        ||      }t        ||      } ||      } ||      }|dv r.|j                  j                  }	t	        j
                  ||	      }nt	        j                  |      }t        j                  ||       y t        
| )  |||      S )N)rL   rM   r@   int64)r>   )rM   rL   )r
   )astypegetattrr   r
   r   r#   	Timedeltare   assert_almost_equalr7   check_reduce)r9   rG   r:   r>   altres_opexp_oprg   expectedr
   r=   s             r   ro   zTestDatetimeArray.check_reduce~   s    //**W%CS'*FS'*F6*FV,H,, YY\\<<R8<<1""684 7'Wf==r   )__name__
__module____qualname__r8   strboolrB   rH   rP   rT   markparametrizerW   r]   rh   r   Seriesro   __classcell__)r=   s   @r   r3   r3   \   s    D
# t 
/3 /4 /P P P [[Xe}5U 6U.
 [[[4*:;6 <6>		 >C > > >r   r3   c                       e Zd Zy)Test2DCompatN)rt   ru   rv   r   r   r   r~   r~      s    r   r~   )__doc__numpyr   rT   pandas.core.dtypes.dtypesr   pandasr   pandas._testing_testingre   pandas.core.arraysr   pandas.tests.extensionr   fixturer   r   r   r'   r)   r,   r1   ExtensionTestsr3   NDArrayBacked2DTestsr~   r   r   r   <module>r      s       5   , ' 7 7            4>++ 4>n	4,, 	r   