
    bMh                        d dl m Z  d dlZd dlZd dlZd dlmZ d dlZd dlm	Z	m
Z
mZ d dlmZ d dlmZ d dlmZmZ d Zd Z ej        eeee
gg d	
          d             Z G d d          Z G d d          Z G d d          ZdS )    )datetimeN)PYPY)	DataFrameIndexSeries)PandasDelegate)NoNewAttributesMixinPandasObjectc                 ,    t          d| ifi |d         S )Nar   xkwargss     c/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pandas/tests/base/test_constructors.pyseries_via_frame_from_dictr      s!    c1X((((--    c                 (    t          | fi |d         S )Nr   r   r   s     r   series_via_frame_from_scalarr      s    Q!!&!!!$$r   )r   zDataFrame-dictzDataFrame-arrayr   )paramsidsc                     | j         S N)param)requests    r   constructorr      s     =r   c                       e Zd Z G d d          Z G d dee          Zd Zej	        
                    ed          d             Zd	S )
TestPandasDelegatec                   H    e Zd ZdgZdgZd Zd Z eeed          Zd Z	dS )	TestPandasDelegate.Delegatorproptest_methodc                     || _         d S r   r!   )selfvalues     r   	_set_propz&TestPandasDelegate.Delegator._set_prop1   s    DIIIr   c                     | j         S r   r$   )r%   s    r   	_get_propz&TestPandasDelegate.Delegator._get_prop4   s
    9r   zfoo property)docc                     dS )za test methodN )r%   argsr   s      r   r"   z(TestPandasDelegate.Delegator.test_method9   s      r   N)
__name__
__module____qualname___properties_methodsr'   r)   propertyr!   r"   r,   r   r   	Delegatorr    -   sg        h!?	 	 		 	 	 x	9.AAA	  	  	  	  	 r   r4   c                       e Zd ZddZdS )TestPandasDelegate.DelegatereturnNc                     || _         d S r   )obj)r%   r9   s     r   __init__z$TestPandasDelegate.Delegate.__init__=   s    DHHHr   )r7   N)r.   r/   r0   r:   r,   r   r   Delegater6   <   s(        	 	 	 	 	 	r   r;   c                 n   | j                             | j        | j        j        d           | j                             | j        | j        j        d           |                      |                                           }d}t          j        t          |          5  |j         d d d            n# 1 swxY w Y   d}t          j        t          |          5  d|_        d d d            n# 1 swxY w Y   d}t          j        t          |          5  |j         d d d            d S # 1 swxY w Y   d S )Nr3   )delegate	accessorstypmethodz#You cannot access the property propmatchzThe property prop cannot be set   )	r;   _add_delegate_accessorsr4   r1   r2   pytestraises	TypeErrorr!   )r%   r=   msgs      r   test_invalid_delegationz*TestPandasDelegate.test_invalid_delegation@   s   
 	--^n0 	. 	
 	
 	

 	--^t~/FH 	. 	
 	
 	
 ==!1!1223]9C000 	 	MM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 0]9C000 	 	HM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 4]9C000 	 	MM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s6   B11B58B5C--C14C1D**D.1D.znot relevant for PyPy)reasonc                 |    |                      |                                           }t          j        |           d S r   )r;   r4   sys	getsizeof)r%   r=   s     r   test_memory_usagez$TestPandasDelegate.test_memory_usage\   s5    
 ==!1!122hr   N)r.   r/   r0   r4   r   r
   r;   rI   rE   markskipifr   rN   r,   r   r   r   r   ,   s                           ><     8 [%<==    >=     r   r   c                       e Zd Zd ZdS )TestNoNewAttributesMixinc                     G d dt                     } |            }t          |d          rJ d|_        |j        dk    sJ |                                 dt	          |          v sJ t          |d          sJ d}t          j        t          |          5  d|_	        d d d            n# 1 swxY w Y   t          |d          rJ d S )Nc                       e Zd ZdS ).TestNoNewAttributesMixin.test_mixin.<locals>.TN)r.   r/   r0   r,   r   r   TrU   g   s        Dr   rV   __frozentestz You cannot add any new attributerA   b)
r	   hasattrr   _freezedirgetattrrE   rF   AttributeErrorrY   )r%   rV   trH   s       r   
test_mixinz#TestNoNewAttributesMixin.test_mixinf   s2   	 	 	 	 	$ 	 	 	 ACC1j)))))sf}}}}			SVV####q*%%%%%0]>555 	 	AC	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 1c??"""""s   B..B25B2N)r.   r/   r0   r`   r,   r   r   rR   rR   e   s#        # # # # #r   rR   c                   .   e Zd Zej                            d ej        dgd           ej         eddd          ge	           ej         ej
        dd          ge	           ej        dge	          gg d	          d
             Zd Zd ZdS )TestConstructionr   z
2263-01-01datetime64[D]dtypei     D)rc   zobject-datetime.datetimezobject-numpy-scalarobject-string)r   c                    |j         j        dk    r ||          }|j         dk    sJ nb ||          }|r!d|j        j        j        v r|j         dk    sJ n|j         dk    sJ t          j        |                                |           d}t          j	        t          j        j        |          5   ||d	           d d d            d S # 1 swxY w Y   d S )
NMzM8[s]rh   stringobjectz4Out of bounds|Out of bounds .* present at position 0rA   zdatetime64[ns]rd   )re   kindnodecallspecidtmassert_numpy_array_equalto_numpyrE   rF   pderrorsOutOfBoundsDatetime)r%   r   r   r   using_infer_stringresultrH   s          r   $test_constructor_datetime_outofboundz5TestConstruction.test_constructor_datetime_outofbound~   s?   . 7<3 [^^F<7***** [^^F! 0o9N9Q&Q&Q|x/////|x////'(9(91=== E]298DDD 	3 	3K!12222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3s   3CCCc                 f   t          j        dgd          }t          j        j        j                            ||j                  } ||          }|j        |j        k    sJ  ||          }t          j	        ||           d|j
        _         ||          }t          j	        ||           d S )Nz2020-01-01T00:00:00.000000zdatetime64[us]rd   F)nparrayrt   corearraysDatetimeArray_simple_newre   rq   assert_equalflags	writeable)r%   r   arrdtaexpectedrx   s         r   test_constructor_datetime_nonnsz0TestConstruction.test_constructor_datetime_nonns   s    h45=MNNNgn*66s#)6LL;s##~****S!!
))) $	S!!
)))))r   c                 
   ddd} ||                                 d          }|r|j        dk    sJ n|j        dk    sJ  |t          |                                           d          }t          j        ||           d S )Nrf      )r   rY   strrd   rl   )keysre   listrq   r   )r%   r   rw   drx   r   s         r   test_constructor_from_dict_keysz0TestConstruction.test_constructor_from_dict_keys   s    !QVVXXU333 	,<5(((((<8++++;tAFFHH~~U;;;
)))))r   N)r.   r/   r0   rE   rO   parametrizer{   r|   r   rl   
datetime64ry   r   r   r,   r   r   rb   rb   z   s         [BHl^?;;;BHhhtQ**+6:::BHmbmL#667vFFFBHl^6222		

 
 
   3 3 34* * *	* 	* 	* 	* 	*r   rb   )r   rL   numpyr{   rE   pandas.compatr   pandasrt   r   r   r   pandas._testing_testingrq   pandas.core.accessorr   pandas.core.baser	   r
   r   r   fixturer   r   rR   rb   r,   r   r   <module>r      s         



                        
       / / / / / /       . . .% % % "$	 	A@@    6  6  6  6  6  6  6  6 r# # # # # # # #*D* D* D* D* D* D* D* D* D* D*r   