
    Owg                         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y)    )datetimeN)PYPY)	DataFrameIndexSeries)PandasDelegate)NoNewAttributesMixinPandasObjectc                 $    t        d| ifi |d   S )Nar   xkwargss     Z/var/www/horilla/myenv/lib/python3.12/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                  j                  ed      d        Zy	)
TestPandasDelegatec                   @    e Zd ZdgZdgZd Zd Z eeed      Zd Z	y)	TestPandasDelegate.Delegatorproptest_methodc                     || _         y r   r!   )selfvalues     r   	_set_propz&TestPandasDelegate.Delegator._set_prop1   s	    DIr   c                     | j                   S r   r$   )r%   s    r   	_get_propz&TestPandasDelegate.Delegator._get_prop4   s    99r   zfoo property)docc                      y)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    -   s/    h!?		 	9.A	 r   r4   c                       e Zd ZddZy)TestPandasDelegate.DelegateNc                     || _         y r   )obj)r%   r8   s     r   __init__z$TestPandasDelegate.Delegate.__init__=   s	    DHr   )returnN)r.   r/   r0   r9   r,   r   r   Delegater6   <   s    	r   r;   c                    | j                   j                  | j                  | j                  j                  d       | j                   j                  | j                  | j                  j                  d       | j                  | j                               }d}t        j                  t        |      5  |j                   d d d        d}t        j                  t        |      5  d|_        d d d        d}t        j                  t        |      5  |j                   d d d        y # 1 sw Y   ixY w# 1 sw Y   HxY w# 1 sw Y   y xY w)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   
 	--^^nn00 	. 	

 	--^^t~~/F/FH 	. 	
 ==!123]]9C0 	MM	 0]]9C0 	HM	 4]]9C0 	MM	 		 		 		 	s$   5D*'D6E*D36D?Eznot relevant for PyPy)reasonc                 l    | j                  | j                               }t        j                  |       y r   )r;   r4   sys	getsizeof)r%   r=   s     r   test_memory_usagez$TestPandasDelegate.test_memory_usage\   s%    
 ==!12hr   N)r.   r/   r0   r4   r   r
   r;   rI   rE   markskipifr   rN   r,   r   r   r   r   ,   sH       >< 8 [[%<=  > r   r   c                       e Zd Zd Zy)TestNoNewAttributesMixinc                 d    G d dt               } |       }t        |d      rJ d|_        |j                  dk(  sJ |j                          dt	        |      v sJ t        |d      sJ d}t        j                  t        |      5  d|_	        d d d        t        |d      rJ y # 1 sw Y   xY w)Nc                       e Zd Zy).TestNoNewAttributesMixin.test_mixin.<locals>.TN)r.   r/   r0   r,   r   r   TrU   g   s    r   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   s    	$ 	 C1j)))ssf}}			SV###q*%%%0]]>5 	AC	 1c?""?	 	s   B&&B/N)r.   r/   r0   r`   r,   r   r   rR   rR   e   s    #r   rR   c                   0   e Zd Zej                  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y)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(  stJ  ||      }|r3d|j                  j                  j                  v r|j                   dk(  sJ |j                   dk(  sJ t        j                  |j                         |       d}t        j                  t        j                  j                  |      5   ||d	       d d d        y # 1 sw Y   y xY w)
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    . 77<<3 ^F<<7*** ^F!o9N9N9Q9Q&Q||x///||x///''(91= E]]29988D 	3!12	3 	3 	3s   C**C3c                    t        j                  dgd      }t        j                  j                  j
                  j                  ||j                        } ||      }|j                  |j                  k(  sJ  ||      }t        j                  ||       d|j                  _         ||      }t        j                  ||       y )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    hh45=MNggnn**66s#))6Ls#~~***S!
) $		S!
)r   N)r.   r/   r0   rE   rO   parametrizer{   r|   r   rl   
datetime64ry   r   r,   r   r   rb   rb   z   s     [[BHHl^?;BHHhtQ*+6:BHHmbmmL#67vFBHHl^62		

  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 r# #*9* 9*r   