o
    TiG                     @   s  d Z ddlZddlZddl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d Zejdd	 Zejd
d Zejdd Zejdd Zejdd Zejdd ZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZ G dd dej!Z"G d d! d!ej#Z$G d"d# d#ej%Z&G d$d% d%ej'Z(G d&d' d'ej)Z*G d(d) d)ej+Z,G d*d+ d+ej-Z.G d,d- d-ej/Z0G d.d/ d/ej1Z2G d0d1 d1ej3Z4G d2d3 d3ej5Z6dS )4aj  
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CategoricalCategoricalDtype)basec                  C   s6   	 t jdjttjdd} | d | d kr	 | S q)NT   d   )sizer      )nprandomZdefault_rngchoiceliststringascii_letters)values r   g/var/www/html/evchargy.com/venv/lib/python3.10/site-packages/pandas/tests/extension/test_categorical.py	make_data   s   r   c                   C   s   t  S Nr   r   r   r   r   dtype'   s   r   c                   C   s
   t t S )zLength-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   r   data,   s   
r   c                   C   s   t tjdgS )zLength 2 array with [NA, Valid]A)r   r   nanr   r   r   r   data_missing6   s   r   c                   C   s   t g dg dddS )N)r   BC)r   r   r   T
categoriesorderedr   r   r   r   r   data_for_sorting<      r    c                   C   s   t g dddgddS )N)r   Nr   r   r   Tr   r   r   r   r   r   data_missing_for_sortingA   r!   r"   c                   C   s   t g dS )N)ar#   NNbr$   r#   cr   r   r   r   r   data_for_groupingF   s   r&   c                   @      e Zd ZdS )	TestDtypeN__name__
__module____qualname__r   r   r   r   r(   K       r(   c                       s2   e Zd Zejjdd fddZdd Z  ZS )TestInterfacezMemory usage doesn't matchreasonc                       t  | d S r   )supertest_memory_usageselfr   	__class__r   r   r3   P   s   zTestInterface.test_memory_usagec                 C   s   |j j}||   }|d |v sJ |d |v sJ ||v s!J ||vs'J tjD ]}||u r1q*||vs7J ||v s=J q*d S )Nr   )r   na_valueZisnatmZNULL_OBJECTS)r5   r   r   r8   Zna_value_objr   r   r   test_containsU   s   
zTestInterface.test_contains)	r*   r+   r,   pytestmarkxfailr3   r:   __classcell__r   r   r6   r   r.   O   s    r.   c                   @      e Zd Zdd ZdS )TestConstructorsc                 C   s:   |  }|jd|d}t||sJ |jtg ksJ d S )N)   )r   )Zconstruct_array_type_empty
isinstancer   r   )r5   r   clsresultr   r   r   
test_emptyo   s   zTestConstructors.test_emptyN)r*   r+   r,   rF   r   r   r   r   r@   n       r@   c                   @   r'   )TestReshapingNr)   r   r   r   r   rH   y   r-   rH   c                       s*   e Zd Zejjdd fddZ  ZS )TestGetitemzBackwards compatibilityr/   c                    r1   r   )r2   test_getitem_scalarr4   r6   r   r   rJ   ~   s   zTestGetitem.test_getitem_scalar)r*   r+   r,   r;   r<   skiprJ   r>   r   r   r6   r   rI   }   s    rI   c                   @   r'   )TestSetitemNr)   r   r   r   r   rL      r-   rL   c                   @   r'   )	TestIndexNr)   r   r   r   r   rM      r-   rM   c                   @   r'   )TestMissingNr)   r   r   r   r   rN      r-   rN   c                   @   r'   )
TestReduceNr)   r   r   r   r   rO      r-   rO   c                   @   r'   )TestAccumulateNr)   r   r   r   r   rP      r-   rP   c                       sL   e Zd Zejjdd fddZdd Zejddd	gd
d Z	  Z
S )TestMethodszUnobserved categories includedr/   c                    s   t  ||S r   )r2   test_value_counts)r5   Zall_dataZdropnar6   r   r   rR      s   zTestMethods.test_value_countsc                    s   |d\}}t |}t |}||dd }t dd tt|t|D }t|| |jd  | dd }t  fddt|D }t|| d S )	Nr   c                 S      | | S r   r   x1Zx2r   r   r   <lambda>       z.TestMethods.test_combine_add.<locals>.<lambda>c                 S   s   g | ]\}}|| qS r   r   ).0r#   r$   r   r   r   
<listcomp>   s    z0TestMethods.test_combine_add.<locals>.<listcomp>r   c                 S   rS   r   r   rT   r   r   r   rV      rW   c                    s   g | ]}|  qS r   r   )rX   r#   valr   r   rY      s    )pdZSeriescombinezipr   r9   Zassert_series_equalZiloc)r5   Zdata_repeatedZ
orig_data1Z
orig_data2s1s2rE   expectedr   rZ   r   test_combine_add   s   


zTestMethods.test_combine_add	na_actionNignorec                 C   s"   |j dd |d}t|| d S )Nc                 S   s   | S r   r   )xr   r   r   rV      s    z&TestMethods.test_map.<locals>.<lambda>)rc   )mapr9   Zassert_extension_array_equal)r5   r   rc   rE   r   r   r   test_map   s   zTestMethods.test_map)r*   r+   r,   r;   r<   r=   rR   rb   Zparametrizerg   r>   r   r   r6   r   rQ      s    rQ   c                   @   r'   )TestCastingNr)   r   r   r   r   rh      r-   rh   c                       s(   e Zd Z fddZ fddZ  ZS )TestArithmeticOpsc                    4   |}|dkr|j tjjdd t || d S N__rmod__z/rmod never called when string is first argumentr/   )node
add_markerr;   r<   r=   r2   test_arith_frame_with_scalarr5   r   Zall_arithmetic_operatorsrequestop_namer6   r   r   ro      s   z.TestArithmeticOps.test_arith_frame_with_scalarc                    rj   rk   )rm   rn   r;   r<   r=   r2   test_arith_series_with_scalarrp   r6   r   r   rs      s   z/TestArithmeticOps.test_arith_series_with_scalar)r*   r+   r,   ro   rs   r>   r   r   r6   r   ri      s    ri   c                       s   e Zd Z fddZ  ZS )TestComparisonOpsc                    sj   d|j  d}|dvr,d}tjt|d ||| W d    d S 1 s%w   Y  d S t ||||S )N__)__eq____ne__z7Unordered Categoricals can only compare equality or not)match)r*   r;   Zraises	TypeErrorr2   _compare_other)r5   sr   opotherrr   msgr6   r   r   rz      s   "z TestComparisonOps._compare_other)r*   r+   r,   rz   r>   r   r   r6   r   rt      s    rt   c                   @   r'   )TestParsingNr)   r   r   r   r   r      r-   r   c                   @   r?   )Test2DCompatc                 C   sH   t |dd}|ddksJ t |dd}|ddks"J d S )Nr
   z
Categories)reprZreshapecount)r5   r   resr   r   r   test_repr_2d   s   zTest2DCompat.test_repr_2dN)r*   r+   r,   r   r   r   r   r   r      rG   r   )7__doc__r   numpyr   r;   Zpandasr\   r   Zpandas._testingZ_testingr9   Zpandas.api.typesr   Zpandas.tests.extensionr   r   Zfixturer   r   r   r    r"   r&   ZBaseDtypeTestsr(   ZBaseInterfaceTestsr.   ZBaseConstructorsTestsr@   ZBaseReshapingTestsrH   ZBaseGetitemTestsrI   ZBaseSetitemTestsrL   ZBaseIndexTestsrM   ZBaseMissingTestsrN   ZBaseReduceTestsrO   ZBaseAccumulateTestsrP   ZBaseMethodsTestsrQ   ZBaseCastingTestsrh   ZBaseArithmeticOpsTestsri   ZBaseComparisonOpsTestsrt   ZBaseParsingTestsr   ZNDArrayBacked2DTestsr   r   r   r   r   <module>   sL    

	



	