o
    g                     @   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 Zejddgd	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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 d0d1 d1e
j+Z,G d2d3 d3e
j-Z.G d4d5 d5e
j/Z0dS )6aj  
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StringDtype)basec                 C   s&   | j jdkrtd dd }|| S )Npyarrowzchunked array n/ac                 S   sZ   dd l }| j}t|d }|g |d | j||d  j}|jdks'J t| |S )Nr      )r   _datalenchunked_arraychunks
num_chunkstype)arrpaarrow_arraysplit r   `/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/pandas/tests/extension/test_string.py_split_array   s   z!split_array.<locals>._split_array)dtypestoragepytestskip)r   r   r   r   r   split_array   s   
r   TF)paramsc                 C   s   | j S N)param)requestr   r   r   chunked,      r   c                 C   s
   t | dS )N)r   r   )string_storager   r   r   r   1   s   
r   c                 C   sj   t jjttjdd}|d |d kr&t jjttjdd}|d |d ks|  |}|r3t|S |S )Nd   )sizer      )	nprandomchoiceliststringascii_lettersconstruct_array_type_from_sequencer   )r   r   stringsr   r   r   r   data6   s   r,   c                 C   s$   |   tjdg}|rt|S |S )zLength 2 array with [NA, Valid]Ar)   r*   pdNAr   r   r   r   r   r   r   data_missing@   s   r2   c                 C   s"   |   g d}|rt|S |S )N)BCr-   )r)   r*   r   r1   r   r   r   data_for_sortingG   s   r5   c                 C   s&   |   dtjdg}|rt|S |S )Nr3   r-   r.   r1   r   r   r   data_missing_for_sortingM   s   r6   c                   C   s   t jS r   )r/   r0   r   r   r   r   na_valueS   r   r7   c              
   C   s2   |   ddtjtjddddg}|rt|S |S )Nr3   r-   r4   r.   r1   r   r   r   data_for_groupingX   s   r8   c                          e Zd Z fddZ  ZS )	TestDtypec                    s&   |d|j  dksJ t | d S )Nzstring[])r   supertest_eq_with_str)selfr   	__class__r   r   r=   a   s   zTestDtype.test_eq_with_str)__name__
__module____qualname__r=   __classcell__r   r   r?   r   r:   `       r:   c                       r9   )TestInterfacec                    6   |j jdkrtjjdd}|j| t | d S Nr   znot implementedreason)	r   r   r   markxfailnode
add_markerr<   	test_viewr>   r,   r   rK   r?   r   r   rO   g      zTestInterface.test_view)rA   rB   rC   rO   rD   r   r   r?   r   rF   f   rE   rF   c                   @   s   e Zd Zdd ZdS )TestConstructorsc                 C      d S r   r   r>   r,   r   r   r   test_from_dtypeo      z TestConstructors.test_from_dtypeN)rA   rB   rC   rU   r   r   r   r   rR   n   s    rR   c                       r9   )TestReshapingc                    rG   rH   )	r   r   r   rK   rL   rM   rN   r<   test_transposerP   r?   r   r   rX   u   rQ   zTestReshaping.test_transpose)rA   rB   rC   rX   rD   r   r   r?   r   rW   t   rE   rW   c                   @      e Zd ZdS )TestGetitemNrA   rB   rC   r   r   r   r   rZ   |       rZ   c                       r9   )TestSetitemc                    rG   rH   )	r   r   r   rK   rL   rM   rN   r<   test_setitem_preserves_viewsrP   r?   r   r   r^      rQ   z(TestSetitem.test_setitem_preserves_views)rA   rB   rC   r^   rD   r   r   r?   r   r]      rE   r]   c                   @   rY   )TestMissingNr[   r   r   r   r   r_      r\   r_   c                   @   s&   e Zd Zejdddgdd ZdS )TestNoReduceskipnaTFc                 C   sZ   |}|dv rd S t |}tt t|||d W d    d S 1 s&w   Y  d S )N)minmax)ra   )r/   Seriesr   raises	TypeErrorgetattr)r>   r,   all_numeric_reductionsra   op_namesr   r   r   test_reduce_series_numeric   s   
"z'TestNoReduce.test_reduce_series_numericN)rA   rB   rC   r   rK   parametrizerk   r   r   r   r   r`      s    r`   c                       s@   e Zd Zejjdd fddZejjdddd Z  ZS )TestMethodszreturns nullablerI   c                    s   t  ||S r   )r<   test_value_counts)r>   all_datadropnar?   r   r   rn      s   zTestMethods.test_value_countsc                 C   rS   r   r   rT   r   r   r    test_value_counts_with_normalize   rV   z,TestMethods.test_value_counts_with_normalize)	rA   rB   rC   r   rK   r   rn   rq   rD   r   r   r?   r   rm      s
    rm   c                   @   rY   )TestCastingNr[   r   r   r   r   rr      r\   rr   c                   @   s   e Zd Zdd Zdd ZdS )TestComparisonOpsc                 C   s8   t |||}t |t||d}| || d S )Nboolean)rg   astypeobjectassert_series_equal)r>   rj   r,   ri   otherresultexpectedr   r   r   _compare_other   s   z TestComparisonOps._compare_otherc                 C   s"   |}t |}| |||d d S )Nabc)r/   rd   r{   )r>   r,   all_compare_operatorsri   rj   r   r   r   test_compare_scalar   s   
z%TestComparisonOps.test_compare_scalarN)rA   rB   rC   r{   r~   r   r   r   r   rs      s    rs   c                   @   rY   )TestParsingNr[   r   r   r   r   r      r\   r   c                   @   rY   )TestPrintingNr[   r   r   r   r   r      r\   r   c                   @   rY   )TestGroupByNr[   r   r   r   r   r      r\   r   )1__doc__r'   numpyr#   r   pandasr/   pandas.core.arrays.string_r   pandas.tests.extensionr   r   fixturer   r   r,   r2   r5   r6   r7   r8   BaseDtypeTestsr:   BaseInterfaceTestsrF   BaseConstructorsTestsrR   BaseReshapingTestsrW   BaseGetitemTestsrZ   BaseSetitemTestsr]   BaseMissingTestsr_   BaseNoReduceTestsr`   BaseMethodsTestsrm   BaseCastingTestsrr   BaseComparisonOpsTestsrs   BaseParsingTestsr   BasePrintingTestsr   BaseGroupbyTestsr   r   r   r   r   <module>   sL    


	





