Ë
    ¤eh¬  ã                   ó–  — d 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	 ddl
mZ ddlmZ ddlmZ 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j2                  «      Z G d„ dej6                  «      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)Úusing_pyarrow_string_dtype©ÚCategorical©ÚCategoricalDtype)Úbasec                  ó°   — 	 t         j                  j                  d«      j                  t	        t
        j                  «      d¬«      } | d   | d   k7  r	 | S ŒV)Né   éd   )Úsizer   é   )ÚnpÚrandomÚdefault_rngÚchoiceÚlistÚstringÚascii_letters)Úvaluess    úe/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/pandas/tests/extension/test_categorical.pyÚ	make_datar      sT   € Ø
Ü—‘×&Ñ& qÓ)×0Ñ0´´f×6JÑ6JÓ1KÐRUÐ0ÓVˆð �!‰9˜˜q™	Ò!ØØ€Mð ó    c                  ó   — t        «       S ©Nr   © r   r   Údtyper   )   s   € äÓÐr   c                  ó(   — t        t        «       «      S )zˆLength-100 array for this type.

    * data[0] and data[1] should both be non missing
    * data[0] and data[1] should not be equal
    )r   r   r   r   r   Údatar   .   s   € ô ”y“{Ó#Ð#r   c                  ó8   — t        t        j                  dg«      S )zLength 2 array with [NA, Valid]ÚA)r   r   Únanr   r   r   Údata_missingr"   8   s   € ô œŸ™ �}Ó%Ð%r   c                  ó&   — t        g d¢g d¢d¬«      S )N)r    ÚBÚC)r%   r    r$   T©Ú
categoriesÚorderedr   r   r   r   Údata_for_sortingr)   >   s   € ä’²?ÈDÔQÐQr   c                  ó&   — t        g d¢ddgd¬«      S )N)r    Nr$   r$   r    Tr&   r   r   r   r   Údata_missing_for_sortingr+   C   s   € äÒ'°S¸#°JÈÔMÐMr   c                  ó   — t        g d¢«      S )N)Úar-   NNÚbr.   r-   Úcr   r   r   r   Údata_for_groupingr0   H   s   € äÒAÓBÐBr   c                   ó’  ‡ — e Zd Zej                  j                  d¬«      ˆ fd„«       Zd„ Zd„ Zej                  j                  d¬«      ˆ fd„«       Z
ej                  j                  d¬«      ˆ fd	„«       Zd
„ Zej                  j                  dddg«      d„ «       Zˆ fd„Zˆ fd„Zdej$                  fˆ fd„Zej                  j                  d¬«      ej                  j                  dddg«      ˆ fd„«       «       Zej                  j                  d¬«      ej                  j                  dddg«      ˆ fd„«       «       Zˆ xZS )ÚTestCategoricalzMemory usage doesn't match©Úreasonc                 ó$   •— t         ‰| �  |«       y r   )ÚsuperÚtest_memory_usage©Úselfr   Ú	__class__s     €r   r7   z!TestCategorical.test_memory_usageN   s   ø€ ô 	‰Ñ! $Õ'r   c                 óö   — |j                   j                  }||j                  «           }|d   |v sJ ‚|d   |v sJ ‚||v sJ ‚||vsJ ‚t        j                  D ]  }||u rŒ||vsJ ‚t        «       rŒ||v rŒJ ‚ y )Nr   )r   Úna_valueÚisnaÚtmÚNULL_OBJECTSr   )r9   r   r"   r<   Úna_value_objs        r   Útest_containszTestCategorical.test_containsS   s©   € ð
 —:‘:×&Ñ&ˆà�T—Y‘Y“[�LÑ!ˆð �A‰w˜$‰ÐˆØ˜A‰ ,Ñ.Ð.Ð.ð ˜<Ñ'Ð'Ð'Ø˜tÑ#Ð#Ð#ô ŸO™Oò 	4ˆLØ˜xÑ'ØØ tÑ+Ð+Ð+ä-Õ/Ø# |Ò3Ð3Ð3ñ	4r   c                 óš   — |j                  «       }|j                  d|¬«      }t        ||«      sJ ‚|j                  t	        g «      k(  sJ ‚y )N)é   )r   )Úconstruct_array_typeÚ_emptyÚ
isinstancer   r   )r9   r   ÚclsÚresults       r   Ú
test_emptyzTestCategorical.test_emptym   sL   € Ø×(Ñ(Ó*ˆØ—‘˜D¨�Ó.ˆä˜& #Ô&Ð&Ð&ð �|‰|Ô/°Ó3Ò3Ð3Ñ3r   zBackwards compatibilityc                 ó$   •— t         ‰| �  |«       y r   )r6   Útest_getitem_scalarr8   s     €r   rK   z#TestCategorical.test_getitem_scalarv   s   ø€ ô
 	‰Ñ# DÕ)r   zUnobserved categories includedc                 ó$   •— t         ‰| �  ||«      S r   )r6   Útest_value_counts)r9   Úall_dataÚdropnar:   s      €r   rM   z!TestCategorical.test_value_counts}   s   ø€ ä‰wÑ(¨°6Ó:Ð:r   c                 ó2  —  |d«      \  }}t        j                  |«      }t        j                  |«      }|j                  |d„ «      }t        j                  t        t	        |«      t	        |«      «      D ��cg c]
  \  }}||z   ‘Œ c}}«      }	t        j                  ||	«       |j                  d   }
|j                  |
d„ «      }t        j                  t	        |«      D �cg c]  }||
z   ‘Œ	 c}«      }	t        j                  ||	«       y c c}}w c c}w )Nr
   c                 ó   — | |z   S r   r   ©Úx1Úx2s     r   ú<lambda>z2TestCategorical.test_combine_add.<locals>.<lambda>‡   s
   € ¨r°B©w€ r   r   c                 ó   — | |z   S r   r   rR   s     r   rU   z2TestCategorical.test_combine_add.<locals>.<lambda>Ž   s
   € °°R±€ r   )ÚpdÚSeriesÚcombineÚzipr   r>   Úassert_series_equalÚiloc)r9   Údata_repeatedÚ
orig_data1Ú
orig_data2Ús1Ús2rH   r-   r.   ÚexpectedÚvals              r   Útest_combine_addz TestCategorical.test_combine_add�   sã   € ñ "/¨qÓ!1Ñˆ
�JÜ�Y‰Y�zÓ"ˆÜ�Y‰Y�zÓ"ˆØ—‘˜BÑ 6Ó7ˆÜ—9‘9Ü!$¤T¨*Ó%5´t¸JÓ7GÓ!H×I‘v˜˜1ˆQ�‹UÓIó
ˆô 	×Ñ˜v xÔ0à�g‰g�a‰jˆØ—‘˜CÑ!7Ó8ˆÜ—9‘9¬t°JÓ/?Ö@¨!˜a #›gÒ@ÓAˆÜ
×Ñ˜v xÕ0ùó Jùò As   Á9D
Ã$DÚ	na_actionNÚignorec                 óX   — |j                  d„ |¬«      }t        j                  ||«       y )Nc                 ó   — | S r   r   )Úxs    r   rU   z*TestCategorical.test_map.<locals>.<lambda>”   s   €  A€ r   )re   )Úmapr>   Úassert_extension_array_equal)r9   r   re   rH   s       r   Útest_mapzTestCategorical.test_map’   s$   € à—‘™+°�Ó;ˆÜ
×'Ñ'¨°Õ5r   c                 ó’   •— |}|dk(  r/|j                  t        j                  j                  d¬«      «       t        ‰| �  ||«       y ©NÚ__rmod__z/rmod never called when string is first argumentr3   )ÚapplymarkerÚpytestÚmarkÚxfailr6   Útest_arith_frame_with_scalar©r9   r   Úall_arithmetic_operatorsÚrequestÚop_namer:   s        €r   rt   z,TestCategorical.test_arith_frame_with_scalar—   sI   ø€ à*ˆØ�jÒ Ø×ÑÜ—‘×!Ñ!ØLð "ó ôô
 	‰Ñ,¨T°7Õ;r   c                 ó’   •— |}|dk(  r/|j                  t        j                  j                  d¬«      «       t        ‰| �  ||«       y rn   )rp   rq   rr   rs   r6   Útest_arith_series_with_scalarru   s        €r   rz   z-TestCategorical.test_arith_series_with_scalar¢   sI   ø€ Ø*ˆØ�jÒ Ø×ÑÜ—‘×!Ñ!ØLð "ó ôô
 	‰Ñ-¨d°GÕ<r   Úserc                 óÈ   •— d|j                   › d�}|dvr0d}t        j                  t        |¬«      5   |||«       d d d «       y t        ‰| �  ||||«      S # 1 sw Y   y xY w)NÚ__)Ú__eq__Ú__ne__z7Unordered Categoricals can only compare equality or not)Úmatch)Ú__name__rq   ÚraisesÚ	TypeErrorr6   Ú_compare_other)r9   r{   r   ÚopÚotherrx   Úmsgr:   s          €r   r„   zTestCategorical._compare_other¬   sl   ø€ Ø�r—{‘{�m 2Ð&ˆØÐ.Ñ.ØKˆCÜ—‘œy°Ô4ñ  Ù�4˜”÷ ð  ô ‘7Ñ)¨#¨t°R¸Ó?Ð?÷ ð  ús   ³
AÁA!zCategorical overrides __repr__r   ÚbigÚsmallc                 ó&   •— t         ‰| �  ||«       y r   )r6   Útest_array_repr)r9   r   r   r:   s      €r   r‹   zTestCategorical.test_array_reprµ   s   ø€ ô 	‰Ñ  dÕ+r   ÚTBDÚas_indexTFc                 ó&   •— t         ‰| �  ||«       y r   )r6   Útest_groupby_extension_agg)r9   r�   r0   r:   s      €r   r�   z*TestCategorical.test_groupby_extension_aggº   s   ø€ ô 	‰Ñ*¨8Ð5FÕGr   )r�   Ú
__module__Ú__qualname__rq   rr   rs   r7   rA   rI   ÚskiprK   rM   rd   Úparametrizerl   rt   rz   rW   rX   r„   r‹   r�   Ú__classcell__)r:   s   @r   r2   r2   M   sW  ø„ Ø‡[�[×ÑÐ:ÐÓ;ó(ó <ð(ò4ò44ð ‡[�[×ÑÐ6ÐÓ7ó*ó 8ð*ð ‡[�[×ÑÐ>ÐÓ?ó;ó @ð;ò1ð" ‡[�[×Ñ˜[¨4°Ð*:Ó;ñ6ó <ð6ô	<ô=ð@ "§)¡)õ @ð ‡[�[×ÑÐ>ÐÓ?Ø‡[�[×Ñ˜V e¨WÐ%5Ó6ó,ó 7ó @ð,ð ‡[�[×Ñ˜eÐÓ$Ø‡[�[×Ñ˜Z¨$°¨Ó7óHó 8ó %ôHr   r2   c                   ó   — e Zd Zd„ Zy)ÚTest2DCompatc                 óÈ   — t        |j                  dd«      «      }|j                  d«      dk(  sJ ‚t        |j                  dd«      «      }|j                  d«      dk(  sJ ‚y )Nr   éÿÿÿÿz
Categories)ÚreprÚreshapeÚcount)r9   r   Úress      r   Útest_repr_2dzTest2DCompat.test_repr_2dÁ   s\   € ô �4—<‘<  2Ó&Ó'ˆØ�y‰y˜Ó(¨AÒ-Ð-Ð-ä�4—<‘<  AÓ&Ó'ˆØ�y‰y˜Ó(¨AÒ-Ð-Ñ-r   N)r�   r�   r‘   r�   r   r   r   r–   r–   À   s   „ ó.r   r–   )Ú__doc__r   Únumpyr   rq   Úpandas._configr   ÚpandasrW   r   Úpandas._testingÚ_testingr>   Úpandas.api.typesr   Úpandas.tests.extensionr   r   Úfixturer   r   r"   r)   r+   r0   ÚExtensionTestsr2   ÚNDArrayBacked2DTestsr–   r   r   r   ú<module>r©      së   ðñó ã Û å 5ã Ý Ý Ý -Ý 'òð ‡�ñó ðð ‡�ñ$ó ð$ð ‡�ñ&ó ð&ð
 ‡�ñRó ðRð ‡�ñNó ðNð ‡�ñCó ðCôpH�d×)Ñ)ô pHôf.�4×,Ñ,õ .r   