
    4i+                       S r SSKJr  SSKrSSKJr  SSKrSSKrSSK	J
r
  SSKJr  SSKrSSKJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  S r\R:                  " SS/S9S 5       r\R:                  S 5       r\R:                  S 5       r \R:                  S 5       r!\R:                  S 5       r"\R:                  S 5       r#\R:                  S 5       r$ " S S\RJ                  5      r& " S S\RN                  5      r(S r)g)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/`.

    )annotationsN)cast)HAS_PYARROW)StorageExtensionDtypeis_string_dtype)ArrowStringArrayStringDtype)string_dtype_highest_priority)basec                N   U(       d  U $ U R                   R                  S:w  a  U $ [        R                  " S5      nU R                  n[        U5      S-  nUR                  / US U R                  QX4S  R                  Q5      nUR                  S:X  d   eU R                  U5      $ )Npyarrow   )
dtypestoragepytestimportorskip	_pa_arraylenchunked_arraychunks
num_chunks_from_pyarrow_array)arrchunkedpaarrow_arraysplits        d/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/pandas/tests/extension/test_string.pymaybe_split_arrayr!   &   s    
			i	'
			Y	'B--K!E""B+fu

$
$B{6':'A'ABK !!Q&&&"";//    TF)paramsc                    U R                   $ N)param)requests    r    r   r   7   s    ==r"   c                    U u  p[        XS9$ )N)r   na_valuer
   )string_dtype_argumentsr   r)   s      r    r   r   <   s    .Gw::r"   c                   [         R                  R                  S5      R                  [	        [
        R                  5      SS9nUS   US   :X  aR  [         R                  R                  S5      R                  [	        [
        R                  5      SS9nUS   US   :X  a  MR  U R                  5       R                  X S9n[        X15      $ )Nr   
   )sizer      r   )
nprandomdefault_rngchoiceliststringascii_lettersconstruct_array_type_from_sequencer!   )r   r   stringsr   s       r    datar:   B   s    ii##A&--d63G3G.Hr-RG
!*

"))''*11$v7K7K2LSU1V !*

" 
$
$
&
5
5g
5
KCS**r"   c                t    U R                  5       R                  [        R                  S/U S9n[	        X!5      $ )zLength 2 array with [NA, Valid]Ar/   r7   r8   pdNAr!   r   r   r   s      r    data_missingrA   L   s5     
$
$
&
5
5ruucl%
5
PCS**r"   c                X    U R                  5       R                  / SQU S9n[        X!5      $ )N)BCr<   r/   )r7   r8   r!   r@   s      r    data_for_sortingrE   S   s+    

$
$
&
5
5oU
5
SCS**r"   c                v    U R                  5       R                  S[        R                  S/U S9n[	        X!5      $ )NrC   r<   r/   r=   r@   s      r    data_missing_for_sortingrG   Y   s6    

$
$
&
5
5sBEE36Gu
5
UCS**r"   c           
         U R                  5       R                  SS[        R                  [        R                  SSSS/U S9n[	        X!5      $ )NrC   r<   rD   r/   r=   r@   s      r    data_for_groupingrI   _   sK    

$
$
&
5
5	c255"%%c34E 6 C S**r"   c                     ^  \ rS rSrU 4S jrU 4S jrS rU 4S jrU 4S jrU 4S jr	S r
U 4S	 jrU 4S
 jrS rS rS r    SS jrSS jrSS jrSS jrS rU 4S jrU 4S jrU 4S jrU 4S jrSrU =r$ )TestStringArrayg   c                   > [        [        U" S5      5      5      R                  nUR                  S:X  a%  UR                  [
        R                  L a  SU l        OSU l        [        TU ]%  U5      $ )Nr   r   bool[pyarrow]bool)
nextiterr   r   r)   r>   r?   _combine_le_expected_dtypesupertest_combine_le)selfdata_repeatedr   	__class__s      r    rT   TestStringArray.test_combine_leh   sX    T-*+,22==I%%..BEE*A.=D+.4D+w&}55r"   c                   > [         TU ]  U5        UR                  [        R                  L a  USUR
                   S3:X  d   eg UR
                  S:X  a	  US:X  d   eg g )Nzstring[]r   str)rS   test_eq_with_strr)   r>   r?   r   )rU   r   rW   s     r    r\    TestStringArray.test_eq_with_strp   sX     '>>RUU"gemm_A6666]]i'E>!> (r"   c                (    [        U5      (       d   eg r%   r   )rU   r   s     r    test_is_not_string_type'TestStringArray.test_is_not_string_typey   s     u%%%%r"   c                   > UR                   [        R                  L a3  U(       d,  [        U5      R	                  UR
                  5      nUSL d   eg [        TU ]  U5        g )NF)r)   r0   nantypeis_dtypenamerS   test_is_dtype_from_name)rU   r   using_infer_stringresultrW   s       r    rf   'TestStringArray.test_is_dtype_from_name~   sG    >>RVV#,>%[))%**5FU?"?G+E2r"   c                
  > UR                   [        R                  L aE  U(       d>  [        R                  " [
        SS9   UR                  UR                  5        S S S 5        g [        TU ]%  U5        g ! , (       d  f       g = f)Nz Cannot construct a 'StringDtype'match)
r)   r0   rb   r   raises	TypeErrorconstruct_from_stringre   rS   #test_construct_from_string_own_name)rU   r   rg   rW   s      r    rp   3TestStringArray.test_construct_from_string_own_name   sY    >>RVV#,>y0RS++EJJ7 TS G7> TSs   A44
Bc                   > UR                   R                  S:X  a  [        R                  " SS9  [        TU ]  U5        g Nr   /2D support not implemented for ArrowStringArrayreason)r   r   r   skiprS   	test_viewrU   r:   rW   s     r    rx   TestStringArray.test_view   s/    ::*KKPQ$r"   c                    g r%    rU   r:   s     r    test_from_dtypeTestStringArray.test_from_dtype   s    r"   c                   > UR                   R                  S:X  a  [        R                  " SS9  [        TU ]  U5        g rs   )r   r   r   rw   rS   test_transposery   s     r    r   TestStringArray.test_transpose   s/    ::*KKPQt$r"   c                   > UR                   R                  S:X  a  [        R                  " SS9  [        TU ]  U5        g rs   )r   r   r   rw   rS   test_setitem_preserves_viewsry   s     r    r   ,TestStringArray.test_setitem_preserves_views   s/    ::*KKPQ,T2r"   c                \    UR                  5       nUS/   n[        R                  " X#5        g )Nr.   )dropnatmassert_extension_array_equal)rU   rA   rh   expecteds       r    test_dropna_array!TestStringArray.test_dropna_array   s*    $$&$
''9r"   c                    XR                  5       )    nUS   nUR                  U5      nX1Ld   e[        R                  " X15        g )Nr   )isnafillnar   r   )rU   r:   validrh   s       r    test_fillna_no_op_returns_copy.TestStringArray.test_fillna_no_op_returns_copy   sC    YY[L!QU#!!!
''5r"   c                   UR                  5       nSUl        UR                  US   5      nUS   US   :X  d   e[        R                  " X!5        UR
                  R                  S:X  a#  UR                  US   5      nUS   US   :X  d   eO5[        R                  " [        SS9   UR                  US   SS9  S S S 5        [        R                  " X!5        g ! , (       d  f       N%= f)	NTr.   r   r   zCannot modify read-only arrayrk   F)copy)
r   	_readonlyr   r   r   r   r   r   rm   
ValueError)rU   rA   r:   rh   s       r    test_fillna_readonly$TestStringArray.test_fillna_readonly   s      " \!_-ayLO+++
''; ::*[[a1F!9Q///z1PQLO%8 R
''; RQs   &C
C'c                L    US;   a  [         $ US;   a  [         $ US;   a  [         $ g )N)__mod____rmod__
__divmod____rdivmod____pow____rpow__)__mul____rmul__)__truediv____rtruediv____floordiv____rfloordiv____sub____rsub__)rn   )rU   op_nameobjothers       r    _get_expected_exception'TestStringArray._get_expected_exception   s@      
 
 // 
 
 r"   c                ~    US;   =(       d2    UR                   R                  [        R                  L =(       a    US;   $ )N)minmaxsum)anyall)r   r)   r0   rb   rU   serr   s      r    _supports_reduction#TestStringArray._supports_reduction   s8    // 
II"&&( *>)	
r"   c                N    [        UR                  [        5      (       d   eUS;   $ )N)cummincummaxcumsum)
isinstancer   r   r   s      r    _supports_accumulation&TestStringArray._supports_accumulation   s&    #))%:;;;;888r"   c                   [        [        [        R                  " U5      5      nUS;   aP  Un[	        U[
        5      (       d  [        R                  " U5      OS n[	        U[        5      (       a  [        XW5      nOCUR                  [        R                  L a  [        R                  nOUR                  S:X  a  SnOSnUR                  U5      $ )N)__add____radd__r   rN   boolean)r   r   r   	get_dtyper   r[   r   r)   r0   rb   bool_r   astype)rU   r   r   r   pointwise_resultr   cast_todtype_others           r    _cast_pointwise_result&TestStringArray._cast_pointwise_result   s    [",,s"34--G5?s5K5K",,u-QUK+{337K^^rvv%hhG]]i'%GG&&w//r"   c                V    [         R                  " U5      nU R                  X1US5        g )Nabc)r>   Series_compare_other)rU   r:   comparison_opr   s       r    test_compare_scalar#TestStringArray.test_compare_scalar   s!    iioC}e<r"   c                $   > [         TU ]  X5        g r%   )rS   test_groupby_extension_apply)rU   rI   groupby_apply_oprW   s      r    r   ,TestStringArray.test_groupby_extension_apply   s    ,->Qr"   c                   > [        U" S5      5      R                  nU(       d>  UR                  S:X  a.  [        R                  R                  SS9nUR                  U5        [        TU ]!  U5        g )Nr.   pythonmThe pointwise operation result will be inferred to string[nan, pyarrow], which does not match the input dtyperu   )	rP   r   r   r   markxfailapplymarkerrS   test_combine_add)rU   rV   rg   r'   r   r   rW   s         r    r    TestStringArray.test_combine_add   sb    ]1%&,,!emmx&?;;$$M % D % /r"   c                "  > UR                   nU(       al  US:X  af  UR                  [        R                  L aI  [        (       d  UR
                  S:X  a.  [        R                  R                  SS9nUR                  U5        [        TU ]-  X5        g )Nr   r   r   ru   )r   r)   r>   r?   r   r   r   r   r   r   rS   test_arith_series_with_array)rU   r:   all_arithmetic_operatorsrg   r'   r   r   rW   s          r    r   ,TestStringArray.test_arith_series_with_array  sw     

(J6"%%' : ;;$$M % D %,TLr"   c                   > U(       dH  UR                   R                  S:X  a.  [        R                  R	                  SS9nUR                  U5        [        TU ]  U5        g )Nr   zCasts to objectru   )r   r   r   r   r   r   rS   8test_loc_setitem_with_expansion_preserves_ea_index_dtype)rU   r:   r'   rg   r   rW   s        r    r   HTestStringArray.test_loc_setitem_with_expansion_preserves_ea_index_dtype  sL     "djj&8&8H&D;;$$,=$>D%HNr"   )rR   )r   r[   returnz4type[Exception] | tuple[type[Exception], ...] | None)r   z	pd.Seriesr   r[   r   rO   )r   r[   )__name__
__module____qualname____firstlineno__rT   r\   r_   rf   rp   rx   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes____classcell__)rW   s   @r    rK   rK   g   s    6"&
3? 
%
3
:
6<&	=6
90=R0M$O Or"   rK   c                  @    \ rS rSr\R
                  " SS9S 5       rSrg)Test2DCompati  T)autousec                X    [        U[        5      (       a  [        R                  " SS9  g g )Nrt   ru   )r   r	   r   rw   r}   s     r    arrow_not_supported Test2DCompat.arrow_not_supported   s"    d,--KKPQ .r"   r|   N)r   r   r   r   r   fixturer   r   r|   r"   r    r   r     s    ^^D!R "Rr"   r   c                    U u  p#nU R                  / SQ5      n[        R                  US'   U(       a  [        R                  " U5      nSn[        R
                  " [        US9   UR                  U5        S S S 5        g ! , (       d  f       g = f)N)r   r   r.   zOsearchsorted requires array to be sorted, which is impossible with NAs present.rk   )taker>   r?   r   r   rm   r   searchsorted)rE   	as_seriesbcar   msgs          r     test_searchsorted_with_na_raisesr   &  sl    GA!


	
*CeeCGiin	0  
z	- 
.	-	-s   $A??
B)*__doc__
__future__r   r5   typingr   numpyr0   r   pandas.compatr   pandas.core.dtypes.baser   pandasr>   pandas._testing_testingr   pandas.api.typesr   pandas.core.arraysr	   pandas.core.arrays.string_r   #pandas.tests.arithmetic.test_stringr   pandas.tests.extensionr   r!   r   r   r   r:   rA   rE   rG   rI   ExtensionTestsrK   Dim2CompatTestsr   r   r|   r"   r    <module>r     s    #     % 9   , / 2 M '0" e}% & ; ;
 + + + + + +
 + +
 + +uOd)) uOpR4'' Rr"   