a
    d֘                    @  s  d Z ddlmZ ddlmZmZmZmZ ddlmZ ddl	m
Z
mZ ddl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mZmZmZmZmZmZmZ dd	lmZmZ ddl Z!ddl"m#Z$ dd
l%m&Z& ddl'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z. ddl/m0Z0 ej1dddZ2ddl3m4Z4 ddl5m6Z6 dd Z7ej8e$j9e:ddd Z;ej8dd Z<ej8dd Z=ej8ddgddd Z>ej8dd Z?ej8d d! Z@ej8d"d# ZAej8d$d% ZBG d&d' d'e0jCZDG d(d) d)e0jEZFG d*d+ d+e0jGZHG d,d- d-e0jIZJG d.d/ d/e0jKZLG d0d1 d1e0jMZNG d2d3 d3e0jOZPG d4d5 d5e0jQZRG d6d7 d7e0jSZTG d8d9 d9e0jUZVG d:d; d;e0jWZXG d<d= d=e0jYZZG d>d? d?e0j[Z\G d@dA dAe0j]Z^G dBdC dCe0j_Z`G dDdE dEe0jaZbG dFdG dGe0jcZdG dHdI dIe0jeZfG dJdK dKZgejhidLe$jjdMdN ZkdOdP ZldQdR ZmdSdT ZnejhidUg dVejhidWdXdXdXggdYdZ Zoejhjid[g d\dd]ggg d^dgggd_d`gdadbdc Zpddde Zqejhidfe2r esge2rdgesge2t esge2u e:ge2ve2w exge2ye2w exge2ze2{ e2w exge2|dhe2} fdie2{ fge~ge2e2w e2w egg	djdk Zdldm Zdndo Zdpdq Zdrds Zdtdu Zdvdw Zdxdy Zdzd{ Zd|d} Zd~d Zdd Zejhidej&ejfdgdd Zdd Zdd Zdd Zejhjedddd Zejhjedddd Zdd Zdd Zdd Zejhidddgdd Zdd Zejhidddgddgddggdd Zdd Zejhidddddddggddddddggddddddggddddddggddddddgggdd Zdd Zejhiddddddggdddddggdddddggdddddgggdd Zejhiddedgde:gddgddggddÄ Zejhidddddddggddddddggddddddgggdd̈́ Zddτ Zejhjededэddӄ Zejhiddddddggdddddggdddddggdddddggdddddggdddddgggddք Zejhiddddddggdddddggdddddggdddddggdddddggdddddgggddل Zejhiddddddge2 gdddddge2w ggddބ Zdd Zejhiddg dgdg dgdg dgdg dgd]g dggdd Zejhjdedэdd Zdd Zejhiddddddggdddddggdddddgggdd Zejhiddddddggdddddggdddddgggdd Zejhidg dg dg dg dg dg dg dg d g dg dg dg dg dg dg dg dg d	g d
gdd Zejhidddgddgddgddgddgddggdd Zdd Zejhidg dg dg d g d!g d"g d#gd$d% Zejhid&d'dgd(d) Zejhid&d*dgd+d, Zejhid-d.d/gejhid0d1d2gd3d4ggd5d6 Zejhidddgd7d8 Zejhid9d:d;gejhid<ddgdd]ggd=d> Zejhid?d@dAgdBdC Zejhid<ddgdd]ggdDdE ZdFdG ZdHdI ZdJdK ZdLdM ZdNdO ZdPdQ ZdRdS ZejhidTg dUdVdW ZdXdY ZejhidZd[d\gd]dgd^dgd_dgd`dgdadgdbdgdcdgddd]gejĐdedejhjeedfdgdhdidjgdkdgdldmgdndgdodpgdqed\dd܃gdredd]dpdjggdsdt ZŐdudv ZƐdwdx Zǐdydz Zejhid9d{d|gd}d~ Zɐdd ZejhidTddgdd Zejhidg ddd Z̐dd Zejhidddgddggdd Zΐdd Zejhid9g ddd Zejhid9g ddd Zejhjeddejhidg dejhid9g ddd ZҐdd Zejhidddgdd ZԐdd ZՐdd ZejhidTddgdd Zejhidded\dېddېdgde!ؐdggdd Zِdd Zڐdd ZejhidTddgdd Zejhidddgdd Zݐdd Zސdd Zejhidddgdd ZG dÐdĄ de4ZdŐdƄ ZdǐdȄ Zejhidɐdʐdge2t fddge2u fgd̐d̈́ Zdΐdτ ZejhidLe$jje$j dАdф ZejhidLe$jdҐdӄ ZejhidLe$jdԐdՄ ZejhidLe$je$j d֐dׄ Zdؐdل Zejhjede2jdэdېd܄ Zdݐdބ ZejhidLe$je$j dߐd ZejhidLe$je$j dd ZejhidLe$je$j dd ZejhidLe$je$j dd ZejhidLe$je$j dd ZejhidLe$je$j dd Zdd ZejhidLe$je$j dd Zdd Zdd ZejhidLe$jdd Zdd ZdS (  ag  
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/`.
    )annotations)datedatetimetime	timedelta)Decimal)BytesIOStringION)lib)PY311is_ci_environmentis_platform_windowspa_version_under7p0pa_version_under8p0pa_version_under9p0pa_version_under11p0pa_version_under13p0)
ArrowDtypeCategoricalDtypeType)
no_default)is_bool_dtypeis_float_dtypeis_integer_dtypeis_numeric_dtypeis_signed_integer_dtypeis_string_dtypeis_unsigned_integer_dtype)basepyarrowz7.0.0)Z
minversion)ArrowExtensionArray)ArrowPeriodTypec                 C  s.   t  r*t r*tjjtjdd}| j| d S )Nz_TODO: Set ARROW_TIMEZONE_DATABASE environment variable on CI to path to the tzdata for pyarrow.raisesreason)	r   r   pytestmarkxfailpaArrowInvalidnode
add_marker)requestr%    r,   j/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/pandas/tests/extension/test_arrow.py_require_timezone_databaseF   s    r.   )paramsidsc                 C  s   t | jdS )N)pyarrow_dtype)r   param)r+   r,   r,   r-   dtypeR   s    r3   c              	   C  s|  | j }tj|rBddgd d g ddgd  d g ddg }n,tj|r~ddgd d g ddgd  d g d	d
g }ntj|rddgd d g ddgd  d g ddg }ntj|rddgd d g ddgd  d g ddg }nxtj|rLtdtdgd d g tdtdgd  d g tdtdg }n"tj	|rt
dddt
dddgd d g t
dddt
dddgd  d g t
dddt
dddg }ntj|r<tdddddddtdddddddgd d g tddddtddddgd  d g tdddtdddg }n2tj|rtdtddgd d g tdtdgd  d g tdtdg }ntj|rtddtddgd d g tddtddgd  d g tddtddg }n|tj|r.dd gd d g dd!gd  d g d"d#g }n@tj|rjd$d%gd d g d&d'gd  d g d(d)g }nttj|| d*S )+NTF   ,         ?        g       g            ?g     X@   r   c      10.0z-2.0z-1.0z0.5z33.123            i
      ab2!>   a   b   1   2   !   >r3   )r1   r'   types
is_booleanis_floatingis_signed_integeris_unsigned_integer
is_decimalr   is_dater   is_timestampr   is_durationr   is_timer   	is_string	is_binaryNotImplementedErrorpdarray)r3   pa_dtypedatar,   r,   r-   rc   W   s    0000*..rc   c                 C  s   t | jd| d g| jdS )zLength-2 array with [NA, Valid]Nr   rR   type_from_sequencer3   )rc   r,   r,   r-   data_missing   s    rg   )r/   c                 C  s    | j dkr|S | j dkr|S dS )zParametrized fixture returning 'data' or 'data_missing' integer arrays.

    Used to test dtype conversion with and without missing values.
    rc   rg   N)r2   )r+   rc   rg   r,   r,   r-   all_data   s    

rh   c              	   C  s  | j }tj|r"d}d}d}n~tj|r>d}d}d}nbtj|rZd}d}d}nFtj|rvd}d}d	}n*tj|rtd
dd}tddd}tddd}ntj	|rt
d
dddddd}t
ddd}t
dddd}ntj|rtd}td}tdd}ntj|r<tdd}tdd}tdd}ndtj|rXd}d}d}nHtj|rtd}d}d}n,tj|rtd}td}td}nttj||dd||||g| dS )z
    Data for factorization, grouping, and unique tests.

    Expected to be like [B, B, NA, NA, A, A, B, C]

    Where A < B < C and NA is missing
    FTgr7   g?r;   r   r9   rE   rA   rB   rC   i  r@   rD   r4   rG   rH   crL   rM      cz-1.1r?   z1.1NrR   )r1   r'   rS   rT   rU   rV   rW   rY   r   rZ   r   r[   r   r\   r   r]   r^   rX   r   r_   r`   ra   )r3   rb   ABCr,   r,   r-   data_for_grouping   s^    	


rn   c                 C  s&   t | j| d | d | d g| jdS )zn
    Length-3 array with a known sort order.

    This should be three items [B, C, A] with
    A < B < C
    r      r4   rR   rd   rn   r,   r,   r-   data_for_sorting   s    rq   c                 C  s&   t | j| d | d | d g| jdS )z{
    Length-3 array with a known sort order.

    This should be three items [B, NA, A] with
    A < B and NA missing.
    r   r=   r4   rR   rd   rp   r,   r,   r-   data_missing_for_sorting   s    rr   c                 C  sR   | j j}tj|s8tj|s8tj|s8tj|rNtj	dgd | j dS | S )z3Length-100 array in which all the elements are two.r=   d   rR   )
r3   r1   r'   rS   
is_integerrU   rX   r[   r`   ra   rc   rb   r,   r,   r-   data_for_twos   s    



rv   c                      s   e Zd Z fddZ  ZS )TestBaseCastingc                   sB   |j j}tj|r2|jtjj	d| dd t
 | d S )NzFor z .astype(str) decodes.r#   )r3   r1   r'   rS   r^   r)   r*   r$   r%   r&   supertest_astype_strselfrc   r+   rb   	__class__r,   r-   rz     s    
zTestBaseCasting.test_astype_str)__name__
__module____qualname__rz   __classcell__r,   r,   r}   r-   rw     s   rw   c                      s4   e Zd Z fddZdd Zdd Zdd Z  ZS )	TestConstructorsc                   sb   |j j}tj|s tj|rRtj|r2d}n
d| }|jtj	j
|d t | d S )Nz1ArrowDtype(pa.string()) != StringDtype('pyarrow')$pyarrow.type_for_alias cannot infer rx   )r3   r1   r'   rS   r]   rX   r)   r*   r$   r%   r&   ry   test_from_dtype)r|   rc   r+   rb   r#   r}   r,   r-   r     s    
z TestConstructors.test_from_dtypec                 C  sd   t ||j}t|| t|jtjs.J t ||j }t|| t|jtjs`J d S N)	re   rf   	_pa_arraytmassert_extension_array_equal
isinstancer'   ZChunkedArraycombine_chunksr|   rc   resultr,   r,   r-   test_from_sequence_pa_array(  s    z,TestConstructors.test_from_sequence_pa_arrayc                 C  sF   t jtdd$ tjdgt d W d    n1 s80    Y  d S )NzConverting strings tomatchz12-1rR   )r$   r"   r_   r   _from_sequence_of_stringsr'   Zmonth_day_nano_interval)r|   r+   r,   r,   r-   *test_from_sequence_pa_array_notimplemented3  s    
z;TestConstructors.test_from_sequence_pa_array_notimplementedc                 C  s   |j j}tj|r:|dr:ts:|jt	j
jdd n\trxtj|sVtj|rx|jt	j
jtjd| d ntj|r|jd urt| |jt }t|j||j d}t|| | }t|j||j d}t|| d S )Nz
time64[ns]z&Nanosecond time parsing not supported.rx   z pyarrow doesn't support parsing r!   rR   )r3   r1   r'   rS   Z	is_time64equalsr   r)   r*   r$   r%   r&   r   r[   rX   ArrowNotImplementedErrorrZ   tzr.   r   caststringre   r   r   r   r   )r|   rc   r+   rb   pa_arrayr   r,   r,   r-   &test_from_sequence_of_strings_pa_array9  s4    

z7TestConstructors.test_from_sequence_of_strings_pa_array)r   r   r   r   r   r   r   r   r,   r,   r}   r-   r     s   r   c                   @  s   e Zd ZdS )TestGetitemTestsNr   r   r   r,   r,   r,   r-   r   V  s   r   c                      sH   e Zd Zdd ZddddddZejd	d
dg fddZ  Z	S )TestBaseAccumulateTestsc                 C  s   t |||d}|jj}tj|rL|jdkr4d}nd}||}||}|d}t |d||d}tj	||dd d S )Nskipna    zint32[pyarrow]int64[pyarrow]Float64F)Zcheck_dtype)
getattrr3   r1   r'   rS   is_temporalZ	bit_widthastyper   assert_series_equal)r|   serop_namer   r   pa_typeZint_typeexpectedr,   r,   r-   check_accumulate[  s    



z(TestBaseAccumulateTests.check_accumulatez	pd.Seriesstrbool)r   r   returnc                 C  s   |j j}tj|s,tj|s,tj|r:|dv rdS nJtj|rT|dv rdS n0tj|r|dkrxtj	|sxdS |dkrdS dS )N)cumsumcumprodcummaxcumminF)r   r   r   r   r   T)
r3   r1   r'   rS   r]   r^   rX   rT   r   r[   )r|   r   r   r   r,   r,   r-   _supports_accumulationl  s$    


z.TestBaseAccumulateTests._supports_accumulationr   TFc           
        s   |j j}|}t|}| ||s2t |||S tsBtr|dkr|j	j
}|jrjd|jv rjt| d tjj| dd}	|j|	 nB|dkrtj|stj|r|jtjj| d| td | ||| d S )Nr   znot slowz  not implemented for pyarrow < 9rx   z not implemented for r#   r"   )r3   r1   r`   Seriesr   ry   test_accumulate_seriesr   r   configoptionZmarkexprr$   skipr%   r&   r)   r*   r'   rS   rT   rX   r_   r   )
r|   rc   Zall_numeric_accumulationsr   r+   r   r   r   optr%   r}   r,   r-   r     sB    


z.TestBaseAccumulateTests.test_accumulate_series)
r   r   r   r   r   r$   r%   parametrizer   r   r,   r,   r}   r-   r   Z  s   r   c                      s   e Zd ZdddddZdd Zejdd	d
g fddZejdd	d
g fddZ	ddddZ
ejdd	d
g fddZejdg ddd Z  ZS )
TestReducer   r   r   r   c                 C  s   t |}|j}tj|r@|dv r@tj|r:|dv r:qddS n$tj|sXtj|rd|dv rddS tj|rtj|s|dv rdS dS )N)sumvarskewkurtprod)r   F)	r   meanmedianr   stdsemr   r   r   )anyallT)	r   	get_dtyper1   r'   rS   r   r[   r]   r^   )r|   objr   r3   rb   r,   r,   r-   _supports_reduction  s*    




zTestReduce._supports_reductionc                 C  s   |j j}|dkrt|| }nt|||d}tj|sFtj|rP|d}|dkrft|| }nt|||d}t	|| d S )Ncountr   r   )
r3   r1   r   r'   rS   rt   rU   r   r   Zassert_almost_equal)r|   r   r   r   rb   r   r   r,   r,   r-   check_reduce  s    
zTestReduce.check_reducer   TFc                   s   |j }|j}tjjt| dtj d| d}|dv rT|jsF|j	dkrT|j
| nr|dv rztrztj|rz|j
| nL|dkrtr|jstj|r|j
| n tj|r|dv r|j
| t ||| d S )	N is not implemented in pyarrow= for r!   >   r   r   rH   >   r   r   r   r   >   r   r   r   r   )r3   r1   r$   r%   r&   	TypeErrorr'   __version___is_numerickindr)   r*   r   rS   rX   r   r   rT   ry   test_reduce_series_numeric)r|   rc   all_numeric_reductionsr   r+   r3   rb   
xfail_markr}   r,   r-   r     sF    

z%TestReduce.test_reduce_series_numericc                   s^   |j j}tjjt| dtj d| d}tj	|sBtj
|rN|j| t |||S )Nr   r   r!   )r3   r1   r$   r%   r&   r   r'   r   rS   r]   r^   r)   r*   ry   test_reduce_series_boolean)r|   rc   all_boolean_reductionsr   na_valuer+   rb   r   r}   r,   r-   r     s    z%TestReduce.test_reduce_series_booleanr   c                 C  sX   |dv r|j }nD|j jdkr2|dvr,|j }qTd}n"|dv r@d}ndddd|j j }|S )	N)maxminzdecimal128(7, 3)[pyarrow])r   r   r   float64[pyarrow])r   r   r   r   r   r   zuint64[pyarrow])iuf)r3   namer   )r|   arrr   Z	cmp_dtyper,   r,   r-   _get_expected_reduction_dtype   s    z(TestReduce._get_expected_reduction_dtypec                   s>   |}|dkr.|j jr.tjjdd}|j| t |||S )Nr   zskew not implementedrx   )	r3   r   r$   r%   r&   r)   r*   ry   test_reduce_frame)r|   rc   r   r   r+   r   r%   r}   r,   r-   r   2  s    zTestReduce.test_reduce_frametyp)int64Zuint64float64c                 C  s,   t jddg| dd }|dks(J d S )Nr9   r=   	[pyarrow]rR         ?)r`   r   r   )r|   r   r   r,   r,   r-   test_median_not_approximate;  s    z&TestReduce.test_median_not_approximate)r   r   r   r   r   r$   r%   r   r   r   r   r   r   r   r,   r,   r}   r-   r     s   ,%r   c                      s   e Zd Z fddZ  ZS )TestBaseGroupbyc                   s   |j }t|rtg d|g dd}tdg}td| }tjt	|d |
d  W d    n1 sv0    Y  |
djdd	j}t|| nt | d S )
N)r9   r9   r=   r=      r   r9   r4   )r9   r9   r9   r9   r9   r9   r9   r9   rk   rl   rm   rm   z%agg function failed [how->sum,dtype->r   rk   T)Znumeric_only)r3   r   r`   	DataFrameIndexreescaper$   r"   r   groupbyr   columnsr   assert_index_equalry   test_in_numeric_groupby)r|   rn   r3   dfr   msgr   r}   r,   r-   r   C  s    ,z'TestBaseGroupby.test_in_numeric_groupby)r   r   r   r   r   r,   r,   r}   r-   r   B  s   r   c                      sH   e Zd Z fddZ fddZdd Z fddZ fd	d
Z  ZS )TestBaseDtypec                   s   |j }tj|r0|jtjjt	d| d tj
|r~d}tjt|d ||j W d    n1 sp0    Y  d S t | d S )Nr   r!   z6string\[pyarrow\] should be constructed by StringDtyper   )r1   r'   rS   rX   r)   r*   r$   r%   r&   r_   r]   r"   r   construct_from_stringr   ry   #test_construct_from_string_own_name)r|   r3   r+   rb   r   r}   r,   r-   r   Y  s    *z1TestBaseDtype.test_construct_from_string_own_namec                   sb   |j }tj|r(t||jr^J n6tj|rR|j	t
jjtd| d t | d S )Nr   r!   )r1   r'   rS   r]   re   Zis_dtyper   rX   r)   r*   r$   r%   r&   r_   ry   test_is_dtype_from_namer|   r3   r+   rb   r}   r,   r-   r   m  s    z%TestBaseDtype.test_is_dtype_from_namec                 C  sD   d}t jt|d t|d W d    n1 s60    Y  d S )Nz*'another_type' must end with '\[pyarrow\]'r   Zanother_type)r$   r"   r   re   r   )r|   r3   r   r,   r,   r-   .test_construct_from_string_another_type_raises|  s    z<TestBaseDtype.test_construct_from_string_another_type_raisesc                   sx   |j }tj|sLtj|sLtj|r4|jd usLtj|sLtj|rh|j	
tjj| dd t | d S )NzB does not have associated numpy dtype findable by find_common_typerx   )r1   r'   rS   rY   r\   rZ   r   r^   rX   r)   r*   r$   r%   r&   ry   test_get_common_dtyper   r}   r,   r-   r     s&    




z#TestBaseDtype.test_get_common_dtypec                   s0   |j }tj|r t|s,J nt | d S r   )r1   r'   rS   r]   r   ry   test_is_not_string_type)r|   r3   rb   r}   r,   r-   r     s    z%TestBaseDtype.test_is_not_string_type)	r   r   r   r   r   r   r   r   r   r,   r,   r}   r-   r   X  s
   r   c                   @  s   e Zd ZdS )TestBaseIndexNr   r,   r,   r,   r-   r     s   r   c                      s,   e Zd Zejjddd fddZ  ZS )TestBaseInterfacez6GH 45419: pyarrow.ChunkedArray does not support views.Fr#   runc                   s   t  | d S r   )ry   	test_viewr|   rc   r}   r,   r-   r    s    zTestBaseInterface.test_view)r   r   r   r$   r%   r&   r  r   r,   r,   r}   r-   r     s   r   c                   @  s   e Zd Zdd ZdS )TestBaseMissingc                 C  s`   ||    }|d }||}||us,J t|| |jdd}||usPJ t|| d S )Nr   Zbackfill)method)isnafillnar   r   )r|   rc   Zvalidr   r,   r,   r-   test_fillna_no_op_returns_copy  s    
z.TestBaseMissing.test_fillna_no_op_returns_copyN)r   r   r   r	  r,   r,   r,   r-   r    s   r  c                   @  s   e Zd ZdS )TestBasePrintingNr   r,   r,   r,   r-   r
    s   r
  c                      s,   e Zd Zejjddd fddZ  ZS )TestBaseReshaping5GH 45419: pyarrow.ChunkedArray does not support viewsFr  c                   s   t  | d S r   )ry   test_transposer  r}   r,   r-   r    s    z TestBaseReshaping.test_transpose)r   r   r   r$   r%   r&   r  r   r,   r,   r}   r-   r    s   r  c                      s,   e Zd Zejjddd fddZ  ZS )TestBaseSetitemr  Fr  c                   s   t  | d S r   )ry   test_setitem_preserves_viewsr  r}   r,   r-   r    s    z,TestBaseSetitem.test_setitem_preserves_views)r   r   r   r$   r%   r&   r  r   r,   r,   r}   r-   r    s   r  c                   @  s8   e Zd Zejddegejdddgdd ZdS )	TestBaseParsingdtype_backendr   engineri   pythonc           
      C  s  |j j}tj|r6|jtjj	t
d| dd nRtj|rf|jdv rf|jtjj	tdd n"tj|r|jtjj	dd tdtj|t|j d	i}|jd
tjd}tj|rt|}nt|}tj|dt|j i||d}|}	t||	 d S )NzParameterized types z not supported.r!   )usnsz1https://github.com/pandas-dev/pandas/issues/49767z)CSV parsers don't correctly handle binaryrx   Z
with_dtyperR   F)indexZna_rep)r3   r  r  )r3   r1   r'   rS   rX   r)   r*   r$   r%   r&   r_   rZ   unit
ValueErrorr^   r`   r   r   r   Zto_csvnpnanr   r	   Zread_csvr   assert_frame_equal)
r|   r  rc   r  r+   rb   r   Z
csv_outputr   r   r,   r,   r-   test_EA_types  s@    

zTestBaseParsing.test_EA_typesN)r   r   r   r$   r%   r   r   r  r,   r,   r,   r-   r    s   r  c                      s   e Zd Z fddZ  ZS )TestBaseUnaryOpsc                   sP   |j j}tj|s@tj|s@|jtj	j
tjd| d t | d S )Nz$pyarrow.compute.invert does support r!   )r3   r1   r'   rS   rT   rt   r)   r*   r$   r%   r&   r   ry   test_invertr{   r}   r,   r-   r    s    zTestBaseUnaryOps.test_invert)r   r   r   r  r   r,   r,   r}   r-   r    s   r  c                      s   e Zd Zejdddg fddZdd Z fdd	Zejd
dddddde	j
fdde	j
fddg fddZdZ  ZS )TestBaseMethodsperiodsr9   r:   c              	     sV   |j j}tj|rD|dkrD|jtjj	tj
d| d| dd t || d S )Nr9   z
diff with z and periods=z will overflowr!   )r3   r1   r'   rS   rW   r)   r*   r$   r%   r&   r(   ry   	test_diff)r|   rc   r   r+   rb   r}   r,   r-   r!    s    zTestBaseMethods.test_diffc                 C  s.   |d d }|  }|jtt ks*J d S )NrE   )Zvalue_countsr3   r   r'   r   r   r,   r,   r-   'test_value_counts_returns_pyarrow_int64  s    z7TestBaseMethods.test_value_counts_returns_pyarrow_int64c                   sL   |j j}tj|r8tr8|jtj	j
d| tjd t ||| d S NzNo pyarrow kernel for r   )r3   r1   r'   rS   rX   r   r)   r*   r$   r%   r&   r   ry   test_argmin_argmax)r|   rq   rr   r   r+   rb   r}   r,   r-   r$    s    z"TestBaseMethods.test_argmin_argmaxzop_name, skipna, expected)idxmaxTr   )idxminTr=   )argmaxTr   )argminTr=   r%  Fr&  )r'  Fr;   )r(  Fr;   c                   sR   |j j}tj|r<tr<|r<|jtj	j
d| tjd t |||| d S r#  )r3   r1   r'   rS   rX   r   r)   r*   r$   r%   r&   r   ry   test_argreduce_series)r|   rr   r   r   r   r+   rb   r}   r,   r-   r)     s    z%TestBaseMethods.test_argreduce_serieszbool[pyarrow])r   r   r   r$   r%   r   r!  r"  r$  r  r  r)  Z_combine_le_expected_dtyper   r,   r,   r}   r-   r    s$   

r  c                      sv   e Zd ZeZdd ZddddZdd Zdd	d
ddZdd Z	 fddZ
 fddZdd Z fddZ  ZS )TestBaseArithmeticOpsc                 C  s8   | d}|dkrdd }|S |dkr.dd S t|S )N_rtruedivc                 S  s   t || S r   )r  dividexyr,   r,   r-   r,  G  s    z8TestBaseArithmeticOps.get_op_from_name.<locals>.rtruedivZ	rfloordivc                 S  s   t || S r   )r  Zfloor_divider.  r,   r,   r-   <lambda>L      z8TestBaseArithmeticOps.get_op_from_name.<locals>.<lambda>)stripr   get_op_from_name)r|   r   Zshort_opnamer,  r,   r,   r-   r4  B  s    
z&TestBaseArithmeticOps.get_op_from_namer   r   c                 C  sx  |}d}t |tjr@d}|jd d df }|jd d df j}n
|}|j}|j}	|st |tjrtj	|	stj
|	r|dvstj|	stj|	stj|	stj|	s|S nH|dkrtj
|	stj|	stj|	stj|	stj|	s|S t|j}
tj|
jr|tj|	rBtj|	r<d}nd}n&|	j}t|ttfv rh|dv rhd	}|
d
| d}
ntj|
jr6tj|	r6t|||}t|}t |tsJ |dkrt |trtt }nF|dkrt |tjr|j|krtt }ntj|js,J ||S |
|	}
t|j|
}|rjtj||j|jd}n
t|}|S )NFTr   )__truediv____rtruediv____floordiv__mss)r9  r8  r  z	duration[]__pow__)r  r   ) r   r`   r   ilocr3   r1   r   r'   rS   rU   rt   r[   rZ   rY   rX   ra   Z_valuesre   Z	is_date64r  r   r   r   r   r   r   r   r   r   r   r  r   )r|   r   r   otherZpointwise_resultr   Z	was_frameZexpected_dataZoriginal_dtypeZorig_pa_typeZpa_expectedr  ZaltZ	alt_dtypeZpd_expectedr,   r,   r-   _cast_pointwise_resultP  s    




	





	





z,TestBaseArithmeticOps._cast_pointwise_resultc                 C  s<   t  o:|dv s|dv r(t r(tj|p:|dv o:tj|S )N__add____radd__r5  r6  r7  __rfloordiv____sub____rsub__)r   r   r'   rS   r[   r   )r|   opnamerb   r,   r,   r-   _is_temporal_supported  s    
	
z,TestBaseArithmeticOps._is_temporal_supportedztype[Exception] | Noner   c                 C  s   |dv r| j S t|}|j}| ||}|dv r8t}n`|rBd }nV|dv rhtj|sbtj	|rhd }n0tj
|stj|stj|stj}nd }|S )N)
__divmod____rdivmod__>   __mod____rmod__r?  )
divmod_excr   r   r1   rH  r_   r'   rS   r]   r^   rU   rt   rX   r   )r|   r   r   r=  r3   rb   arrow_temporal_supportedexcr,   r,   r-   _get_expected_exception  s0    





z-TestBaseArithmeticOps._get_expected_exceptionc                 C  s0  d }|  ||}|dkrVtj|s<tj|s<tj|rVtsVtjj	d| d}n|rtj
|sz|dv rtj|rtjj	t| d| dd}n|dkrtj|stj|rtstjj	tjd	d}n\|d
krtj|rtstjj	tjd	d}n0|dkr,tj|r,tr,tjj	tjdd}|S )N__rpow__z<GH#29997: 1**pandas.NA == 1 while 1**pyarrow.NA == NULL for rx   rB  z  not supported betweenpd.NA and z Python scalarr!   rC  zdivide by 0r6  r;  z'Invalid decimal function: power_checked)rH  r'   rS   rU   rt   rX   r   r$   r%   r&   r\   r[   r   r(   )r|   rG  rb   r%   rN  r,   r,   r-   _get_arith_xfail_marker  s    


	





z-TestBaseArithmeticOps._get_arith_xfail_markerc                   sd   |j j}|dkr2tj|s(tj|r2td | ||}|d urR|j	
| t || d S NrL  z%Skip testing Python string formatting)r3   r1   r'   rS   r]   r^   r$   r   rR  r)   r*   ry   test_arith_series_with_scalarr|   rc   all_arithmetic_operatorsr+   rb   r%   r}   r,   r-   rT  '  s    


z3TestBaseArithmeticOps.test_arith_series_with_scalarc                   sd   |j j}|dkr2tj|s(tj|r2td | ||}|d urR|j	
| t || d S rS  )r3   r1   r'   rS   r]   r^   r$   r   rR  r)   r*   ry   test_arith_frame_with_scalarrU  r}   r,   r-   rW  5  s    


z2TestBaseArithmeticOps.test_arith_frame_with_scalarc           	      C  s   |j j}|dv r@tj|r@ts@|jtj	j
tjd| d | ||}|d ur`|j| |}t|}ttj|jd gt| |j d}| ||| d S )NrD  zJImplemented pyarrow.compute.subtract_checked which raises on overflow for r!   r   rR   )r3   r1   r'   rS   rW   r   r)   r*   r$   r%   r&   r(   rR  r`   r   ra   r<  lenZcheck_opname)	r|   rc   rV  r+   rb   r%   r   r   r=  r,   r,   r-   test_arith_series_with_arrayC  s0    
	

&z2TestBaseArithmeticOps.test_arith_series_with_arrayc                   sB   |j j}|dr2|jtjjtj	d| d t
 | d S )Nint8zraises on overflow for r!   )r3   r1   r   r)   r*   r$   r%   r&   r'   r(   ry   $test_add_series_with_extension_arrayr{   r}   r,   r-   r[  e  s    
z:TestBaseArithmeticOps.test_add_series_with_extension_array)r   r   r   r_   rM  r4  r>  rH  rP  rR  rT  rW  rY  r[  r   r,   r,   r}   r-   r*  ?  s   c$A"r*  c                      s>   e Zd Z fddZdd Zejdg ddd Z  Z	S )	TestBaseComparisonOpsc                   s   t |}t t j|jd gt| |jd}|jdv r|||}|d |u sTJ |d |u sdJ |||}||d< ||d< t	|| nt
 ||S d S )Nr   rR   )eqne   a   )r`   r   ra   r<  rX  r3   r   combiner   r   ry   test_compare_array)r|   rc   comparison_opr   r   r=  r   r   r}   r,   r-   rb  s  s    
&

z(TestBaseComparisonOps.test_compare_arrayc                 C  s>   t jtdd ||t  W d    n1 s00    Y  d S )Nz'.* not implemented for <class 'object'>r   )r$   r"   r_   object)r|   rc   rc  r,   r,   r-   test_invalid_other_comp  s    z-TestBaseComparisonOps.test_invalid_other_compmasked_dtype)booleanZInt64r   c           	      C  s   g d}t j||d}t j||  dd}|||}|tjtjtjfv rVg d}ng d}t j|tt	 d}t
|| d S )N)r9   r   NrR   r   )FFN)TTN)r`   r   loweroperatorltgtr^  r   r'   bool_r   r   )	r|   rf  rc  rc   
ser_maskedser_par   expr   r,   r,   r-   test_comp_masked_numpy  s    

z,TestBaseComparisonOps.test_comp_masked_numpy)
r   r   r   rb  re  r$   r%   r   rp  r   r,   r,   r}   r-   r\  r  s   r\  c                   @  sf  e Zd ZdZdd Zejddg dfej	g dfdg dfe
dg dfd	g d
fe
d	g d
fgdd Zdd Zejddg dfej	g dfdg d
fd	g dfe
dg d
fe
d	g dfgdd Zdd Zejddg dfej	g dfdg dfe
dg dfe
d	g d
fgdd Zejdddgddgdd	ggdd ZdS )TestLogicalOpsz1Various Series and DataFrame logical ops methods.c                 C  s   t jdgd dgd  d gd  dd}t jg dd dd}||B }t jg ddd}t|| ||B }t|| t|t jdgd dgd  d gd  dd t|t jg dd dd d S )NTr   Fboolean[pyarrow]rR   TFN)	TTTTFNTNNr`   r   r   r   r|   rG   rH   r   r   r,   r,   r-   test_kleene_or  s"    (&zTestLogicalOps.test_kleene_orzother, expectedN)TNNT)TTTFrs  c                 C  sf   t jg ddd}||B }t j|dd}t|| ||B }t|| t|t jg ddd d S Nrs  rr  rR   rt  r|   r=  r   rG   r   r,   r,   r-   test_kleene_or_scalar  s    z$TestLogicalOps.test_kleene_or_scalarc                 C  s   t jdgd dgd  d gd  dd}t jg dd dd}||@ }t jg ddd}t|| ||@ }t|| t|t jdgd dgd  d gd  dd t|t jg dd dd d S )NTr   Frr  rR   rs  )	TFNFFFNFNrt  ru  r,   r,   r-   test_kleene_and  s"    (&zTestLogicalOps.test_kleene_and)NFNFFFc                 C  sf   t jg ddd}||@ }t j|dd}t|| ||@ }t|| t|t jg ddd d S rw  rt  rx  r,   r,   r-   test_kleene_and_scalar  s    z%TestLogicalOps.test_kleene_and_scalarc                 C  s   t jdgd dgd  d gd  dd}t jg dd dd}||A }t jg ddd}t|| ||A }t|| t|t jdgd dgd  d gd  dd t|t jg dd dd d S )NTr   Frr  rR   rs  )	FTNTFNNNNrt  ru  r,   r,   r-   test_kleene_xor  s"    (&zTestLogicalOps.test_kleene_xorNNN)FTNc                 C  sf   t jg ddd}||A }t j|dd}t|| ||A }t|| t|t jg ddd d S rw  rt  rx  r,   r,   r-   test_kleene_xor_scalar  s    z%TestLogicalOps.test_kleene_xor_scalarzop, exp__and____or____xor__c                 C  s^   g d}t j|dd}t j|dd}t|||}t j|dd gtt d}t|| d S )Nrs  rg  rR   rr  F)r`   r   r   r   r'   rl  r   r   )r|   opro  rc   rm  rn  r   r   r,   r,   r-   test_logical_masked_numpy,  s    
z(TestLogicalOps.test_logical_masked_numpy)r   r   r   __doc__rv  r$   r%   r   r`   NAr  rl  ry  rz  r|  r}  r  r  r,   r,   r,   r-   rq    sX   











rq  r   c                 C  s   t | }tjg d|d}tjg d|d}||B }tjg d|d}t|| ||@ }tjg d|d}t|| ||A }tjg d|d}t|| | }|d  }tj||d| }t|| d S )N)r9   Nr   r4   rR   )Nr   rF   r4   )NNro   r4   )NNr9   r4   )NN   r   r   )	r   r`   r   r   r   r  to_numpymaskZisnull)r   r3   leftrightr   r   r,   r,   r-   test_bitwise>  s     r  c                   C  st   t jtdd td W d    n1 s.0    Y  t jtdd td W d    n1 sf0    Y  d S )NzPassing pyarrow typer   z#not_a_real_dype[s, tz=UTC][pyarrow]zdecimal(7, 2)[pyarrow])r$   r"   r_   r   r   r,   r,   r,   r-   Ftest_arrowdtype_construct_from_string_type_with_unsupported_parametersW  s    (r  c                  C  s*   t d} t tdd}| |ks&J d S )Nztimestamp[s, tz=UTC][pyarrow]r9  UTC)r   r   r'   	timestamp)r3   r   r,   r,   r-   5test_arrowdtype_construct_from_string_supports_dt64tz_  s    
r  c                  C  sL   d} d}t jt|d" tjtd| d W d    n1 s>0    Y  d S )Nzint64[pyarrow]foobar[pyarrow]zYPassing pyarrow type specific parameters \(\[pyarrow\]\) in the string is not supported\.r   r   rR   )r$   r"   r_   r`   r   range)invalidr   r,   r,   r-   ;test_arrowdtype_construct_from_string_type_only_one_pyarrowf  s
    r  interpolation)Zlinearrh  higherZnearestZmidpointquantiler8   c                 C  s^  | j j}| g d} t| }tj|sDtj|sDtj	|rt
rNd}nd}tjtj|d |j||d W d    n1 s0    Y  d S tj|stj|stj|rt
sn2tj| jjrn |jtjjtjd| d | g d} t| }|j||d}tj|r|dvr|jrNd	|j d
|j d}nd	|j d}||}	|	j||d}
|dkr|jdkr|
jdd}
||
ksJ n,|jdkr|
jd}
t !||
| j  d S |dkr|| d ksZJ nftj| ddgddgd}
tj|s:tj|s:tj|rN|
d}
|d}t !||
 d S )Nr   r   r   z;Function quantile has no kernel matching input types \(.*\)z=Function 'quantile' has no kernel matching input types \(.*\)r   )qr  z&quantile not supported by pyarrow for r!   )rh  r  zM8[z, r:  r8   r  F)warnr   r  r   )"r3   r1   taker`   r   r'   rS   r]   r^   rT   r   r$   r"   r   r  rt   rU   rX   r   r   re   r)   r*   r%   r&   rZ   r   r  r   to_pydatetimedtfloorr   r   )rc   r  r  r+   rb   r   r   r   Zpd_dtypeZser_npr   r,   r,   r-   test_quantileq  sz    



,











r  ztake_idx, exp_idx)r   r   r=   r=   r4   r4   r4   )r   r   r   r=   r4   r4   Z
multi_modeZsingle_mode)r0   c                 C  s@   |  |}t|}|jdd}t|  |}t|| d S )NTZdropna)r  r`   r   moder   r   )rn   Ztake_idxZexp_idxrc   r   r   r   r,   r,   r-   test_mode_dropna_true  s
    

r  c                 C  sx   t jd d | d g| jd}|jdd}t jd g| jd}t|| t jd | d g| jd}|jdd}t|| d S )Nr   rR   Fr  )r`   r   r3   r  r   r   )rc   Z	more_nansr   r   r,   r,   r-   test_mode_dropna_false_mode_na  s    r  zarrow_dtype, expected_type   f1f2c                 C  s   t | j|ksJ d S r   )r   re   )arrow_dtypeexpected_typer,   r,   r-   test_arrow_dtype_type  s    r  c                  C  sh   t tg d} t| sJ tjj| s0J tt	t
| }||  }|t|  }t|| d S )NTFT)r   r'   ra   r   r`   corecommonZis_bool_indexerr   r  rX  r  Zasarrayr   r   )rc   r9  r   r   r,   r,   r-   test_is_bool_dtype  s    r  c                 C  sJ   | j j}tj|s,tj|s,tj|r:t| sFJ nt| rFJ d S r   )r3   r1   r'   rS   rU   rt   rX   r   rc   r   r,   r,   r-   test_is_numeric_dtype  s    


r  c                 C  s2   | j j}tj|r"t| s.J nt| r.J d S r   )r3   r1   r'   rS   rt   r   r  r,   r,   r-   test_is_integer_dtype  s    r  c                 C  s2   | j j}tj|r"t| s.J nt| r.J d S r   )r3   r1   r'   rS   rV   r   r  r,   r,   r-   test_is_signed_integer_dtype  s    r  c                 C  s2   | j j}tj|r"t| s.J nt| r.J d S r   )r3   r1   r'   rS   rW   r   r  r,   r,   r-   test_is_unsigned_integer_dtype  s    r  c                 C  s2   | j j}tj|r"t| s.J nt| r.J d S r   )r3   r1   r'   rS   rU   r   r  r,   r,   r-   test_is_float_dtype  s    r  c                 C  sl   t | }|d}t|}t|}t|t|ks<J t|}t|| t|}t|| d S )Nr=   )	r`   r   headpickledumpsrX  loadsr   r   )rc   r   Zexpected_slicedZfull_pickledZsliced_pickledr   Zresult_slicedr,   r,   r-   test_pickle_roundtrip'  s    





r  c                 C  sH   | j  j}|| j}t|jtr(J t|jts8J t||  d S r   )	r   	to_pandasra   r   r3   r   r   r   r   )rc   Zpd_arrayr   r,   r,   r-   test_astype_from_non_pyarrow7  s
    r  c                  C  s6   t dg} | d}t jdgdd}t|| d S )N1.0r   r6   rR   )r`   r   r   r   r   r   r   r   r,   r,   r-   &test_astype_float_from_non_pyarrow_str@  s    
r  c                 C  s   |   }| jj}tj|s4tj|s4tj|rDt	t
| }nt	| j}| jrp|t}tj|t| < t|| d S r   )r  r   re   r'   rS   r[   rZ   rY   r  ra   list_hasnar   rd  r`   r  r  r   assert_numpy_array_equal)rc   r   r   r   r,   r,   r-   test_to_numpy_with_defaultsH  s    



r  c                  C  sT   dd g} t j| dd}| }tjdt jgtd}t|d tsDJ t	|| d S )Nr9   r   rR   r   )
r`   ra   r  r  r  rd  r   intr   r  )rc   r   r   r   r,   r,   r-   test_to_numpy_int_with_na]  s    r  zna_val, exp)r9   r9   c                 C  sH   t jt jt jgdd}|jd| d}tj|gd dd}t|| d S )Nnull[pyarrow]rR   r   )r3   r   r=   r`   ra   r  r  r  r   r  )Zna_valro  r   r   r   r,   r,   r-   test_to_numpy_null_arrayg  s    r  c                  C  sH   t jt jt jgdd} | jd d}tjt jgd dd}t|| d S )Nr  rR   r=   rd  r  )r   r   r   r,   r,   r-   !test_to_numpy_null_array_no_dtypep  s    r  c                 C  s   |   }|  }| d |d d < tj| d gt|  | jjd}t|| |  }| d d d |d d < | d d d }t|| |  }|  |d d < | }t|| d S )Nr   rR   r;   )	copyr   rf   rX  r   re   r   r   tolist)rc   origr   r   r,   r,   r-   test_setitem_null_slicex  s     r  c                 C  s   | j j}tj|s tj|r.d}t}d}n@tj|sRtj|sRtj	|rbd}tj
}d}nd}t}d}tj||d || d d < W d    n1 s0    Y  d S )N{   zInvalid value '123' for dtypefoozCould not convertzInvalid value 'foo' for dtyper   )r   re   r'   rS   r]   r^   r   rt   rU   rT   r(   r$   r"   )rc   r   Z
fill_valueerrr   r,   r,   r-   test_setitem_invalid_dtype  s&    


r  zreturns object with 7.0rx   c                  C  sv   t jtdtdgt  d} | jt  tt  ijd}tj	tdtdgtt  d}t
|| d S )Nz
2019-12-31re   Ztypes_mapperrR   )r'   ra   r`   	Timestampdate32r  r   Zdate64getr   r   r   )Z
date_arrayr   r   r,   r,   r-   &test_from_arrow_respecting_given_dtype  s    
r  zdoesn't raise with 7c                  C  sh   t jddgt  d} tjt jdd. | jt  tt  ij	d W d    n1 sZ0    Y  d S )Nr         @r  zFloat value 1.5 was truncatedr   r  )
r'   ra   r   r$   r"   r(   r  r   r   r  )ra   r,   r,   r-   -test_from_arrow_respecting_given_dtype_unsafe  s    r  c                  C  s   d} t jdddt jg| d}|d}t jdddt jg| d}t|| t jd	t jd
g| d}|d}t jdt jdg| d}t|| d S )Nr   r7   gGz?g{Gz@rR   r9   g333333?g@g^@gp=
cL@r;   g      ^@g      N@)r`   r   r  roundr   r   )r3   r   r   r   r,   r,   r-   
test_round  s    

r  c                 C  sp   | \}}}|  g d}tj|d< |r0t|}d}tjt|d || W d    n1 sb0    Y  d S )N)r=   r   r9   r;   zOsearchsorted requires array to be sorted, which is impossible with NAs present.r   )r  r`   r  r   r$   r"   r  Zsearchsorted)rq   Z	as_seriesrH   ri   rG   r   r   r,   r,   r-    test_searchsorted_with_na_raises  s    


r  c               
   C  s^   t t jddgttt t dddgd} |  }| j	ddgd	}t
|| d S )
Nr/  r0  rR   r9   r=   )rG   rH   rG   rH   )Zby)r`   r   r   r   r'   
dictionaryint32r   r  Zsort_valuesr   r  )r   r   r   r,   r,   r-   test_sort_values_dictionary  s    r  patabcz	a[a-z]{2}c                 C  sP   t jdd gtt d}|j| }t jdd gtt d}t	|| d S )Nr  rR   r9   )
r`   r   r   r'   r   r   r   r  r   r   )r  r   r   r   r,   r,   r-   test_str_count  s    r  c                  C  s\   t jdd gtt d} tjtdd  | jj	ddd W d    n1 sN0    Y  d S )Nr  rR   z	count notr   r9   flags)
r`   r   r   r'   r   r$   r"   r_   r   r   r   r,   r,   r-    test_str_count_flags_unsupported  s    r  zside, str_funcr  rjustr  ljustZbothcenterc                 C  sb   t jdd gtt d}|jjd| dd}t jtd|ddd gtt d}t	|| d S )NrG   rR   r   r/  )widthsideZfillchar)
r`   r   r   r'   r   r   padr   r   r   )r  Zstr_funcr   r   r   r,   r,   r-   test_str_pad  s    r  c                  C  s\   t jdd gtt d} tjtdd  | j	ddd W d    n1 sN0    Y  d S )NrG   rR   zInvalid side: foor   r   r  r/  )
r`   r   r   r'   r   r$   r"   r  r   r  r  r,   r,   r-   test_str_pad_invalid_side  s    r  zpat, case, na, regex, expabFTZAbz	a[a-z]{1}z	A[a-z]{1}c                 C  sT   t jdd gtt d}|jj| |||d}t j|tt d}t	|| d S )Nr  rR   )casenaregex)
r`   r   r   r'   r   r   containsrl  r   r   )r  r  r  r  ro  r   r   r   r,   r,   r-   test_str_contains	  s    r  c                  C  s\   t jdd gtt d} tjtdd  | jj	ddd W d    n1 sN0    Y  d S )Nr  rR   zcontains notr   rG   r9   r  )
r`   r   r   r'   r   r$   r"   r_   r   r  r  r,   r,   r-   #test_str_contains_flags_unsupported  s    r  zside, pat, na, exp
startswithrH   endswithZbcc                 C  sT   t jdd gtt d}t|j| ||d}t j|tt d}t	|| d S )Nr  rR   )r  
r`   r   r   r'   r   r   r   rl  r   r   )r  r  r  ro  r   r   r   r,   r,   r-   test_str_start_ends_with   s    
r  zarg_name, argreplr  r  r9   c                 C  sr   t jdd gtt d}dddd}||| < tjtdd" |jj	f i | W d    n1 sd0    Y  d S )	Nr  rR   rH   r/  T)r  r  r  zreplace is not supportedr   )
r`   r   r   r'   r   r$   r"   r_   r   replace)Zarg_nameargr   kwargsr,   r,   r-   test_str_replace_unsupported0  s
    r  zpat, repl, n, regex, exprG   r/  r;   ZxbxcZxbacz[a-b]Zxxxcc                 C  sT   t jdd gtt d}|jj| |||d}t j|tt d}t|| d S )NZabacrR   )nr  )	r`   r   r   r'   r   r   r  r   r   )r  r  r  r  ro  r   r   r   r,   r,   r-   test_str_replace<  s    	r  c                  C  s\   t jdd gtt d} tjtdd  | j	ddg W d    n1 sN0    Y  d S )Nr  rR   zrepeat is notr   r9   r=   )
r`   r   r   r'   r   r$   r"   r_   r   repeatr  r,   r,   r-   test_str_repeat_unsupportedK  s    r   zUnsupported for pyarrow < 7r   c                  C  sP   t jdd gtt d} | jd}t jdd gtt d}t|| d S )Nr  rR   r=   Zabcabc)	r`   r   r   r'   r   r   r  r   r   r  r,   r,   r-   test_str_repeatQ  s    r  zpat, case, na, expc                 C  sR   t jdd gtt d}|jj| ||d}t j|tt d}t	|| d S Nr  rR   )r  r  
r`   r   r   r'   r   r   r   rl  r   r   r  r  r  ro  r   r   r   r,   r,   r-   test_str_match]  s    r  ZAbcc                 C  sR   t jdd gtt d}|jj| ||d}t j|tt d}t	|| d S r  r  r  r,   r,   r-   test_str_fullmatcho  s    r  zsub, start, end, exp, exp_typr   r=   c                 C  sN   t jdd gtt d}|jj| ||d}t j|t|d}t|| d S )Nr  rR   )startend)	r`   r   r   r'   r   r   findr   r   )subr  r  ro  Zexp_typr   r   r   r,   r,   r-   test_str_find  s    r  c                  C  s\   t jdd gtt d} tjtdd  | jj	ddd W d    n1 sN0    Y  d S )Nr  rR   zfind not implementedr   r  r9   )r  )
r`   r   r   r'   r   r$   r"   r_   r   r	  r  r,   r,   r-   test_str_find_notimplemented  s    r  zi, exp)rH   eN)ri   r  N)ri   NN)rG   NNr~  c                 C  sL   t jg dtt d}|j| }t j|tt d}t|| d S )N)r  deNrR   )	r`   r   r   r'   r   r   r  r   r   )r   ro  r   r   r   r,   r,   r-   test_str_get  s    r  z=TODO: StringMethods._validate should support Arrow list typesc                  C  sX   t tttdtdd g} | jd}t jg dtt	 d}t
|| d S )Nr  123=za=b=cz1=2=3NrR   )r`   r   r   r'   ra   r  r   joinr   r   r   r   r  r,   r,   r-   test_str_join  s    "r  c                  C  sN   t ttg d} | jd}t jg dtt d}t	
|| d S )N)r  r  Nr  r  rR   )r`   r   r   r'   ra   r   r  r   r   r   r   r  r,   r,   r-   test_str_join_string_type  s    r  zstart, stop, step, expc                 C  sP   t jdd gtt d}|j| ||}t j|tt d}t|| d S NabcdrR   )	r`   r   r   r'   r   r   slicer   r   )r  stopstepro  r   r   r   r,   r,   r-   test_str_slice  s    	r  zstart, stop, repl, expZaxcdZxcdZcdc                 C  sP   t jdd gtt d}|j| ||}t j|tt d}t|| d S r  )	r`   r   r   r'   r   r   Zslice_replacer   r   )r  r  r  ro  r   r   r   r,   r,   r-   test_str_slice_replace  s    	r  zvalue, method, exp)Za1cisalnumT)z!|,r  F)aaaisalphaT)z!!!r   F)u   ٠	isdecimalT)z~!r!  F)rI   isdigitT)~r"  F)r  islowerT)ZaaAr$  F)r  	isnumericT)Z11Ir%  F) isspaceT) r'  F)zThe ThatistitleT)zthe Thatr)  F)ZAAAisupperT)ZAAcr*  Fc                 C  sR   t j| d gtt d}t|j| }t j|d gtt d}t	|| d S NrR   r  )valuer  ro  r   r   r   r,   r,   r-   test_str_is_functions  s    r-  zmethod, exp
capitalizezAbc deftitlezAbc DefswapcasezAbC Defrh  zabc defupperzABC DEFcasefoldc                 C  sR   t jdd gtt d}t|j|  }t j|d gtt d}t|| d S )NzaBc dEFrR   	r`   r   r   r'   r   r   r   r   r   )r  ro  r   r   r   r,   r,   r-   test_str_transform_functions  s    r4  c                  C  sN   t jdd gtt d} | j }t jdd gtt d}t	|| d S )Nr  rR   r4   )
r`   r   r   r'   r   r   rX  r  r   r   r  r,   r,   r-   test_str_len  s    
r5  zmethod, to_strip, val)r3  Nz abc )r3  r/  Zxabcx)lstripNz abc)r6  r/  Zxabc)rstripNzabc )r7  r/  Zabcxc                 C  sV   t j|d gtt d}t|j| |d}t jdd gtt d}t|| d S )NrR   )to_stripr  r3  )r  r8  valr   r   r   r,   r,   r-   test_str_strip
  s    r:  r9  Zabc123c                 C  sP   t j| d gtt d}|jd}t jdd gtt d}t|| d S NrR   r  r  )	r`   r   r   r'   r   r   removesuffixr   r   r9  r   r   r   r,   r,   r-   test_str_removesuffix  s    r>  Z123abcc                 C  sP   t j| d gtt d}|jd}t jdd gtt d}t|| d S r;  )	r`   r   r   r'   r   r   removeprefixr   r   r=  r,   r,   r-   test_str_removeprefix$  s    r@  errorsignorestrictzencoding, exputf8s   abcutf32s     a   b   c   c                 C  sR   t jdd gtt d}|j|| }t j|d gtt d}t	|| d S Nr  rR   )
r`   r   r   r'   r   r   encodebinaryr   r   )rA  encodingro  r   r   r   r,   r,   r-   test_str_encode,  s    	rJ  c                 C  s^   t jg dtt d}|jjd| d}t jdgg d gttt d}t	|| d S )N)r  ZefgNrR   rH   r  )
r`   r   r   r'   r   r   findalllist_r   r   )r  r   r   r   r,   r,   r-   test_str_findall;  s    $rM  r  r  rindexz
start, endc                 C  s   t jdd gtt d}t|j| d||}t jdd gtt d}t	|| t
jtdd$ t|j| d|| W d    n1 s0    Y  d S )NabcbarR   ri   r=   zsubstring not foundr   r  )r`   r   r   r'   r   r   r   r   r   r   r$   r"   r  )r  r  r  r   r   r   r,   r,   r-   test_str_r_indexC  s    	rP  formNFCNFKCc                 C  s>   t jdd gtt d}|j| }| }t	|| d S rF  )
r`   r   r   r'   r   r   	normalizer  r   r   )rQ  r   r   r   r,   r,   r-   test_str_normalizeU  s    rU  c                 C  sT   t jg dtt d}|jd| |}t jg dtt d}t	|| d S )N)rO  r  NrR   ri   )r=   r;   N)
r`   r   r   r'   r   r   rfindr   r   r   )r  r  r   r   r   r,   r,   r-   test_str_rfind]  s    rW  c                  C  sT   t jdd gtt d} | jddi}t jdd gtt d}t|| d S )NrO  rR   r`  rH   Zbbcbb)	r`   r   r   r'   r   r   	translater   r   r  r,   r,   r-   test_str_translatek  s    rY  c                  C  sP   t jdd gtt d} | jd}t jdd gtt d}t|| d S )NrO  rR   r   zabc
ba)	r`   r   r   r'   r   r   wrapr   r   r  r,   r,   r-   test_str_wrapr  s    r[  c                  C  sb   t jg dtt d} | j }t jg dg dg dgtt g dd}t	
|| d S )N)za|bNza|crR   )TTFr{  r  )rG   rH   ri   )r3   r   )r`   r   r   r'   r   r   Zget_dummiesr   rl  r   r  r  r,   r,   r-   test_get_dummiesy  s    

r\  c                  C  s  t jdd gtt d} | jd}t jg dg dgtt d}t	|| | jjddd}t t
tg dd g}t|| | jd}t jg dg dgtt d}t	|| | jjddd}t t
tg dd g}t|| d S )	NrO  rR   rH   )rG   rH   Zcbar~  Fexpand)r  rH   rG   )r`   r   r   r'   r   r   	partitionr   r   r  r   ra   r   
rpartitionr  r,   r,   r-   test_str_partition  s"    ra  c                  C  sf  t jg dtt d} | jd}t ttg dg dd g}t	
|| | jjddd}t ttdd	gd
d	gd g}t	
|| | jjddd}t ttddgddgd g}t	
|| | jjdddd}t ttg dttg dd}t	|| | jjddd}t ttg dttg dd}t	|| d S )NZa1cbcba2cbcbNrR   ri   a1rH   rH   a2rH   rH   r9   r  re  Zbcbrg  z[1-2]T)r  rG   cbcb)r  r^  )rG   rG   N)ri  ri  Nr   r9   r>   r]  rG   rc  Nri  NN)r`   r   r   r'   r   r   splitr   ra   r   r   r   r  r  r,   r,   r-   test_str_split  s<    rn  c                  C  s(  t jg dtt d} | jd}t ttg dg dd g}t	
|| | jjddd}t ttdd	gd
d	gd g}t	
|| | jjdddd}t ttg dttg dd}t	|| | jjddd}t ttg dttg dd}t	|| d S )Nrb  rR   ri   rd  rf  r9   rh  a1cbrH   a2cbT)r  r^  )ro  rp  N)rH   rH   Nrj  r>   r]  rk  rl  )r`   r   r   r'   r   r   rsplitr   ra   r   r   r   r  r  r,   r,   r-   test_str_rsplit  s2    rr  c                  C  sX   t jdd gtt d} tjtdd | j	d W d    n1 sJ0    Y  d S )Nr  rR   z,str.extract not supported with pd.ArrowDtyper   z[ab](\d))
r`   r   r   r'   r   r$   r"   r_   r   extractr  r,   r,   r-   test_str_unsupported_extract  s
    rt  r  )r  r  r8  r9  c                 C  sF   ddg}t | }tj||d}tt jdd g|d}t|| d S )NZ1000NaTrR   i  r  )r'   durationr   r   ra   r   r   )r  stringsr   r   r   r,   r,   r-   #test_duration_from_strings_with_nat  s
    
rx  c                 C  sR   | j j}tj|sNtjtdd t	| j
 W d    n1 sD0    Y  d S )Nz2Can only use .dt accessor with datetimelike valuesr   )r3   r1   r'   rS   r   r$   r"   AttributeErrorr`   r   r  ru   r,   r,   r-   test_unsupported_dt  s    rz  zprop, expectedyear  dayZday_of_weekZ	dayofweekweekdayZday_of_yearZ	dayofyearhourminuteZis_leap_yearz.is_leap_year not implemented for pyarrow < 8.0r!   )ZmarksmicrosecondrF   month
nanosecondr  Zquartersecondro   r   r   c                 C  s   t jt jddddddddd	d gttd
d}t|j| }d }t|t	rVt
 }nt|trjtd
}t ttj|d g|d}t|| d S )Nr|  r9   r=   r   r4   ro   rF   r  )r{  r  r}  r  r  r  r  r  r  rR   r  )r`   r   r  r   r'   r  r   r  r   r   r  r   time64r   ra   r   r   )propr   r   r   Zexp_typer,   r,   r-   test_dt_properties 	  s.    




r  c               	   C  s   t jtdddddtdddddtdddddd gttdd	} | jj}t jg d
tt d	}t	
|| | jj}t jg dtt d	}t	
|| d S )Nr|  rB   r=   r   r{  r  r}  r  r9   rC   r  rR   FTFNFFTN)r`   r   r   r   r'   r  r  Zis_month_startrl  r   r   Zis_month_endr  r,   r,   r-   test_dt_is_month_start_end9	  s    	r  c               	   C  s   t jtdddddtdddddtdddddd gttdd} | jj}t jg d	tt d}t	
|| | jj}t jg d
tt d}t	
|| d S )Nr|  rB   rC   r   r  r9   r  rR   r  )TFFN)r`   r   r   r   r'   r  r  Zis_year_startrl  r   r   Zis_year_endr  r,   r,   r-   test_dt_is_year_start_endL	  s    	r  c               	   C  s   t jtdddddtdddddtdddddd gttdd	} | jj}t jg d
tt d	}t	
|| | jj}t jg dtt d	}t	
|| d S )Nr|        r   r  r9   rC   r  rR   r  r  )r`   r   r   r   r'   r  r  Zis_quarter_startrl  r   r   Zis_quarter_endr  r,   r,   r-   test_dt_is_quarter_start_end_	  s    	r  Zdays_in_monthZdaysinmonthc              	   C  sz   t jtdddddtdddddtdddddd gttdd	}t|j| }t jg d
tt d	}t	
|| d S )Nr|  r   r  r  r4   r9   r=   r  rR   )rC   r     N)r`   r   r   r   r'   r  r   r  r   r   r   )r  r   r   r   r,   r,   r-   test_dt_days_in_monthr	  s    	r  c                  C  s   t jtddddtdddddtdddd	d
d
dd gttdd} | j }t jtddddtddddtddddd gttdd}t	|| d S )Nr|  r   r  r{  r  r}  r4   r9   r  r=      ;   )r{  r  r}  r  r  r  r  rR   )
r`   r   r   r   r'   r  r  rT  r   r   r  r,   r,   r-   test_dt_normalize	  s$    	
	r  r  r  c                 C  sx   t jtdddddd gtt| d}|jj| ks8J |jj}t t	tj
tddd gt| d}t|| d S )	Nr|  r9   r=   r   r  rR   r   r  )r`   r   r   r   r'   r  r  r  r   r   ra   r  r   r   r  r   r   r   r,   r,   r-   test_dt_time_preserve_unit	  s     r  r   )Nr  
US/Pacificc                 C  sD   t jtdddddd gttjd| dd}|jj}|| ks@J d S )	Nr|  r9   r=   r   r  r  r   rR   )r`   r   r   r   r'   r  r  r   )r   r   r   r,   r,   r-   
test_dt_tz	  s    r  c                  C  sb   t jtdddddd gttdd} | j }t jg dg d	gg d
dd}t	
|| d S )Nr|  r9   r=   r   r  r  rR   )r|  r9   r9   r  )r{  weekr}  r   r   r3   )r`   r   r   r   r'   r  r  isocalendarr   r   r  r  r,   r,   r-   test_dt_isocalendar	  s    
r  day_nameZSunday
month_nameJanuaryc                 C  sd   t | tjtdddd gttdd}t|j|  }tj|d gtt	 d}t
|| d S )Nr|  r9   r8  rR   )r.   r`   r   r   r   r'   r  r   r  r   r   r   )r  ro  r+   r   r   r   r,   r,   r-   test_dt_day_month_name	  s
    $r  c                 C  sf   t |  tjtdddddd gttdd}|jd}tjd	d gtt	 d}t
|| d S )
Nr|  r9   r=   r   r  r  rR   z%Y-%m-%dT%H:%M:%Sz2023-01-02T03:00:00.000000000)r.   r`   r   r   r   r'   r  r  strftimer   r   r   )r+   r   r   r   r,   r,   r-   test_dt_strftime	  s    r  )ceilr  r  c                 C  s   t jtdddddd gttdd}tjtdd	$ t	|j
| d
dd W d    n1 s`0    Y  tjtdd	$ t	|j
| d
dd W d    n1 s0    Y  d S )Nr|  r9   r=   r   r  r  rR   zambiguous is not supported.r   Z1Hru  Z	ambiguousznonexistent is not supported.nonexistent)r`   r   r   r   r'   r  r$   r"   r_   r   r  r  r   r,   r,   r-   *test_dt_roundlike_tz_options_not_supported	  s    2r  c                 C  s   t jtdddddd gttdd}tjtdd	  t	|j
| d
 W d    n1 s\0    Y  tjtdd	  t	|j
| d  W d    n1 s0    Y  d S )Nr|  r9   r=   r   r  r  rR   zfreq='1B' is not supportedr   Z1Bz$Must specify a valid frequency: None)r`   r   r   r   r'   r  r$   r"   r  r   r  r  r,   r,   r-   "test_dt_roundlike_unsupported_freq	  s    .r  z'Methods not supported for pyarrow < 7.0freq)DHTSLUNc                 C  sn   t tddddd g}ttd}t|j|d|  |}t||j|d|  }t	
|| d S )Nr|  r9   r  r  r>   )r`   r   r   r   r'   r  r   r  r   r   r   )r  r  r   rb   r   r   r,   r,   r-   test_dt_ceil_year_floor	  s    r  c                  C  s   t dddt dddg} tj| ttdd}d}tjt|d |j	
 }W d    n1 sb0    Y  tj| td}t|| tdd	 |D sJ d
}tjt|d  |dj	
 }W d    n1 s0    Y  t|| d S )Nr@   r9   r|  r  rR   CThe behavior of ArrowTemporalProperties.to_pydatetime is deprecatedr   c                 s  s   | ]}t |tu V  qd S r   )re   r   ).0resr,   r,   r-   	<genexpr>
  r2  z(test_dt_to_pydatetime.<locals>.<genexpr>z>The behavior of DatetimeProperties.to_pydatetime is deprecatedzdatetime64[ns])r   r`   r   r   r'   r  r   assert_produces_warningFutureWarningr  r  r  ra   rd  r  r   r   )rc   r   r   r   r   r,   r,   r-   test_dt_to_pydatetime
  s    (.r  	date_typer   @   c              	   C  s   t jtdddgtttd|   d}d}tjt|dH t	j
tdd |j  W d    n1 sl0    Y  W d    n1 s0    Y  d S )	Nr@   rB   rC   r   rR   r  r   z#to_pydatetime cannot be called with)r`   r   r   r   r   r'   r   r  r  r$   r"   r  r  r  )r  r   r   r,   r,   r-    test_dt_to_pydatetime_date_error
  s    r  c                  C  s   t jtdddddd gttdd} tjtdd	  | j	j
d
dd W d    n1 s\0    Y  tjtdd	  | j	j
d
dd W d    n1 s0    Y  d S )Nr|  r9   r=   r   r  r  rR   z ambiguous='NaT' is not supportedr   r  ru  r  z"nonexistent='NaT' is not supportedr  )r`   r   r   r   r'   r  r$   r"   r_   r  tz_localizer  r,   r,   r-   *test_dt_tz_localize_unsupported_tz_options#
  s    .r  c                  C  sp   t jtdddddd gttjdddd	} | jd }t jtdddddd gttdd	}t	|| d S )
Nr|  r9   r=   r   r  r  r  r  rR   )
r`   r   r   r   r'   r  r  r  r   r   r  r,   r,   r-   test_dt_tz_localize_none/
  s    r  c                 C  s   t | tjtdddddd gtt| d}|jd}tj	tdddddd gt| d}tj
|d}tt|}t|| d S )	Nr|  r9   r=   r   r  rR   r  r  r.   r`   r   r   r   r'   r  r  r  ra   ZcomputeZassume_timezoner   r   r   )r  r+   r   r   exp_datar   r,   r,   r-   test_dt_tz_localize<
  s    r  znonexistent, exp_dateZshift_forwardrB   r  Zshift_backwardz2023-03-12 01:59:59.999999999c                 C  s   t | tjtddddddd gttdd}|jjd	| d
}tj	|d gtdd}tj
|d	}tt|}t|| d S )Nr|  r   rB   r=   r  )r{  r  r}  r  r  r  rR   r  r  r  r  )r  Zexp_dater+   r   r   r  r   r,   r,   r-   test_dt_tz_localize_nonexistentM
  s    r  c                  C  sf   t jtdddddd gttdd} tjtdd	 | j	
d
 W d    n1 sX0    Y  d S )Nr|  r9   r=   r   r  r  rR   z"Cannot convert tz-naive timestampsr   r  )r`   r   r   r   r'   r  r$   r"   r   r  
tz_convertr  r,   r,   r-    test_dt_tz_convert_not_tz_raisesb
  s    r  c                  C  sn   t jtdddddd gttddd} | jd }t jtdddddd gttdd}t	|| d S )	Nr|  r9   r=   r   r  r  r  rR   
r`   r   r   r   r'   r  r  r  r   r   r  r,   r,   r-   test_dt_tz_convert_nonek
  s    r  c                 C  sp   t jtdddddd gtt| dd}|jd}t jtdddddd gtt| dd}t	|| d S )	Nr|  r9   r=   r   r  r  rR   z
US/Easternr  r  r,   r,   r-   test_dt_tz_convertx
  s    r  r   c                 C  sD   t jd gdd}t|| |d}|r.| dk}nt j}||u s@J d S )Nr   rR   r   r   )r`   r   r   r  )r   r   r   r   r   r,   r,   r-   #test_boolean_reduce_series_all_null
  s    
r  c                  C  s   g d} g d}d g}| | | }dgt |  dgt |  d gt |  }tj|t d}tj|dd}t|| ddg}t	j
tjd	d
" tj|t d W d    n1 s0    Y  d S )N)trueTRUETruer>   r  )falseFALSEFalse0r?   TFrR   rr  r  r  zFailed to parser   )rX  r   r   r'   rl  r`   ra   r   r   r$   r"   r(   )Ztrue_stringsZfalse_stringsZnullsrw  Zboolsr   r   r,   r,   r-   %test_from_sequence_of_strings_boolean
  s    (r  c                 C  sB   t jg | d}| }t |tjg tjd g}t|| d S r+  )	r`   r   r  concatr  ra   rl  r   r   )r3   r   r   r   r,   r,   r-   %test_concat_empty_arrow_backed_series
  s    r  r   zstring[pyarrow]c                 C  s>   t d }tj|| d}tjt|| d}t|| d S )Nzthe quick brown foxrR   )r'   ra   rm  r`   r   r   r   r   )r3   r   r   r   r,   r,   r-   test_series_from_string_array
  s    r  c                      s   e Zd Z fddZ  ZS )OldArrowExtensionArrayc                   s   t   }|d|d< |S )Nr   _data)ry   __getstate__pop)r|   stater}   r,   r-   r  
  s    
z#OldArrowExtensionArray.__getstate__)r   r   r   r  r   r,   r,   r}   r-   r  
  s   r  c                  C  sV   t dg} t| }tt|}t|| |jt 	| ksDJ t
|drRJ d S )Nr9   r  )r'   ra   r  r  r  r  r   r   r   chunked_arrayhasattr)rc   r   r   r,   r,   r-   #test_pickle_old_arrowextensionarray
  s    r  c                  C  sT   d} t ttj| ftjdg}| }d|tj| ftjd< |j|jksPJ d S )Nih6 rR   F)	r   r'   r  r  Zonesrl  r  zerosr   )r  r   r   r,   r,   r-   /test_setitem_boolean_replace_with_mask_segfault
  s
    r  zdata, arrow_dtyperL   rM   c                 C  s:   t |}tjt| |d}tj| |d}t|| d S r+  )r   r`   ra   r  r   r   )rc   r  r3   r   r   r,   r,   r-   -test_conversion_large_dtypes_from_numpy_array
  s    r  c                  C  sl   t jdd d gitt d} t jdddgidd}t j| |gdd}t jdg didd}t|| d S )	NrG   rR   r   r9   r   T)Zignore_index)NNr   r9   )r`   r   r   r'   nullr  r   r  )r   Zdf2r   r   r,   r,   r-   test_concat_null_array
  s
    r  c                 C  sN   t jg dt| d}| }t jg dtt g dd}t|| d S )Nr9   r=   r   rR   )r   r=   r9   r9   r   g       @r  r   r   r   r   r   25%50%75%r   r3   r  )r`   r   r   describer'   r   r   r   r   rc   r   r   r,   r,   r-   test_describe_numeric_data
  s    
r  c                 C  s^   t jtddt| d}| }t jdgt jg d| jd  tg dd}t	
|| d S )	Nr9   rE   rR   	   )rF   r=   r9   r   rF   ro   r  r  r  r  )r`   r   r  r   r  to_timedeltar  r  rd  r   r   r  r,   r,   r-   test_describe_timedelta_data
  s    r  c                   sX   t jtddt d}| }t jdg fdddD  tg dd	}t|| d S )
Nr9   rE   rR   r  c                   s    g | ]}t j| j jd qS ))r   r  )r`   r  r   r  )r  vr   r,   r-   
<listcomp>  s   z/test_describe_datetime_data.<locals>.<listcomp>)rF   r9   r   rF   ro   r  )r   r   r   r  r  r  r   r  )r`   r   r  r   r  rd  r   r   r  r,   r  r-   test_describe_datetime_data
  s    
	r  c                 C  s<   g d}t j|t| d}|d}|d }||ks8J d S )Nr  rR   g?r   )r`   r   r   r  )r   rc   r   r   r   r,   r,   r-   test_quantile_temporal  s
    
r  c                  C  sB   t jtdgt  d} tj| t| jd}t	|dks>J d S )Nz
2020-01-01r  rR   z+0    2020-01-01
dtype: date32[day][pyarrow])
r'   ra   r   fromisoformatr  r`   r   r   re   repr)Zarrow_dtr   r,   r,   r-   test_date32_repr  s    r  z9Function 'add_checked' has no kernel matching input typesc                  C  s   t dd g} t dd g}t j| ttdd}t j|ttdd}|| }t jdd gttdd}t	|| d S )Nr9   r  rR   r=   )
r`   to_datetimer  r   r   r'   r  rv  r   r   )Zdata_tsZdata_tdZser_tsZser_tdr   r   r,   r,   r-   2test_duration_overflow_from_ndarray_containing_nat#  s    r  c                 C  s\   t | }|dksJ | jr>|dv r>tjjdd}|j| |t jt| ddksXJ d S )Nzunknown-array)ZfloatingZ
datetime64Ztimedelta64zfin infer_dtype pd.NA is not ignored in these cases even with skipna=True in the list(data) check belowrx   Tr   )	r
   Zinfer_dtyper  r$   r%   r&   r)   r*   r  )rc   r+   r  r%   r,   r,   r-   test_infer_dtype_pyarrow_dtype3  s    
r  c                 C  sz   d}| j }tj| r.tj||d|g}ntj||| jd|g}t	j
|| d}t	tj|g| d}t|| d S )Nr   r  r  r   rR   r  )r  r'   rS   r[   r`   	Timedeltaas_unitr  r   r   rf   ra   r   r   )r   r9  r  seqr   r   r,   r,   r-   test_from_sequence_temporalA  s    r   c                 C  s   | j }tj| r(tjd|d|}ntjd|| jd|}t	tj
g d| d}| }||d d < t	tj
g d| d}t|| d S )Nr9   r  r  r  r  )r9   r9   r9   )r  r'   rS   r[   r`   r  r  r  r   r   ra   r  r   r   r   r  r9  r   r   r   r,   r,   r-   test_setitem_temporalR  s    r  c                 C  s   t r.tj| r.tjjtjdd}|j	| t
tjg d| d}| j}|tjd|d| }t
tjg d| d}t|| d S )Nz>Function 'subtract_checked' has no kernel matching input typesr!   r  r  r9   r  )r   r9   r=   )r   r'   rS   r[   r$   r%   r&   r   r)   r*   r   ra   r  r`   r  r  r   r   )r   r+   r%   r   r  r   r   r,   r,   r-   test_arithmetic_temporale  s    r  c                 C  s   | j }tj| r(tjd|d|}ntjd|| jd|}t	tj
g d| d}||k}t	tj
g dt d}t|| d S )Nr9   r  r  r  r  )FTT)r  r'   rS   r[   r`   r  r  r  r   r   ra   rl  r   r   r  r,   r,   r-   test_comparison_temporalx  s    r  c                 C  s   t tjg d| d}|d }tj| rTtjd| jd| j}t	|tjsJ n,tj
d| j| jd| j}t	|tj
sJ |j|jksJ ||ksJ d S )Nr  r  r9   r=   r  r  )r   r'   ra   rS   r[   r`   r  r  r  r   r  r   r   r   r   r   r,   r,   r-   test_getitem_temporal  s    r  c                 C  s   t tjdd g| d}t|}tj| r^tjd| jd	| jtj
g}t|d tjsJ n6tjd| j| jd	| jtj
g}t|d tjsJ |d j|d jksJ ||ksJ d S )Nr9   r  r  r   r  )r   r'   ra   r  rS   r[   r`   r  r  r  r  r   r  r   r  r,   r,   r-   test_iter_temporal  s    r  c                 C  sR   t j| d d g dd}|jdd }t jddgdd	d
gd}t|| d S )Nr   )rG   rG   rH   r  r   )levelr=   r9   r   rG   rH   r  )r`   r   r   sizer   r   )rc   r   r   r   r,   r,   r-   'test_groupby_series_size_returns_pa_int  s    r
  c                 C  s   t tjdd g| d}| }tj| r^tjd| jd	| jtj
g}t|d tjsJ n6tjd| j| jd	| jtj
g}t|d tjsJ tj|td}|d j|d jksJ t|| d S )Nr9   r  r  r   r  rR   )r   r'   ra   r  rS   r[   r`   r  r  r  r  r   r  r   r  rd  r   r  r  r,   r,   r-   test_to_numpy_temporal  s    r  c                 C  s\   t ddg| | d}|d }t jddggt jdgddddgdd}t|| d S )	Nr9   r   rk   )r   rl   rm   r   )r  r   r3   )r`   r   r   r   r   r   r  )rg   r   r   r   r,   r,   r-   %test_groupby_count_return_arrow_dtype  s    r  c                  C  s@   t jt jddddgttdd} t| }d}||ks<J d S )NZ2012r   )r   colr  r  z#     col
0  15340
1  15341
2  15342)r`   r   Zperiod_ranger   r    r  )r   r   r   r,   r,   r-   'test_arrowextensiondtype_dataframe_repr  s    
r  c                 C  sh   t jd dgt| d}t tjddgd| j dd}||}t jddgt| d}t|| d S )Nr=   rR   r9   r   zm8[r:  )	r`   r   r   r  ra   r  r  r   r   )r   Zser1Zser2r   r   r,   r,   r-   test_duration_fillna_numpy  s
    "
r  c                  C  s   t t dg t dg g} tt| }| \}}tjddgtj	d}t
t|  }t|| t|| d S )NrG   rH   r   r9   rR   )r'   r  ra   Zdictionary_encoder`   r   r   Z	factorizer  Zintpr   r   r   r  r   )r   r   Zres_indicesZres_uniquesZexp_indiciesZexp_uniquesr,   r,   r-   !test_factorize_chunked_dictionary  s    r  )r  
__future__r   r   r   r   r   decimalr   ior   r	   ri  r  r   numpyr  r$   Zpandas._libsr
   Zpandas.compatr   r   r   r   r   r   r   r   Zpandas.core.dtypes.dtypesr   r   Zpandasr`   Zpandas._testingZ_testingr   Zpandas.api.extensionsr   Zpandas.api.typesr   r   r   r   r   r   r   Zpandas.tests.extensionr   Zimportorskipr'   Zpandas.core.arrays.arrow.arrayr   Z(pandas.core.arrays.arrow.extension_typesr    r.   ZfixtureZALL_PYARROW_DTYPESr   r3   rc   rg   rh   rn   rq   rr   rv   ZBaseCastingTestsrw   ZBaseConstructorsTestsr   ZBaseGetitemTestsr   ZBaseAccumulateTestsr   ZBaseReduceTestsr   ZBaseGroupbyTestsr   ZBaseDtypeTestsr   ZBaseIndexTestsr   ZBaseInterfaceTestsr   ZBaseMissingTestsr  ZBasePrintingTestsr
  ZBaseReshapingTestsr  ZBaseSetitemTestsr  ZBaseParsingTestsr  ZBaseUnaryOpsTestsr  ZBaseMethodsTestsr  ZBaseArithmeticOpsTestsr*  ZBaseComparisonOpsTestsr\  rq  r%   r   ZALL_INT_PYARROW_DTYPESr  r  r  r  r  r  r  rH  bytesZlarge_binaryZlarge_stringrL  r   r  Z
large_listZmap_r   structrZ  dictr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  Zskipifr  r  r  r  r  r  r  r  r  r  r  r  compiler  r  r   r&   r_   r  r  r  r  r  r  r  ry  r  r  r  r  r-  r4  r5  r:  r>  r@  rJ  rM  rP  rU  rW  rY  r[  r\  ra  rn  rr  rt  rx  rz  r2   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  ZFLOAT_PYARROW_DTYPESr  ZTIMEDELTA_PYARROW_DTYPESr  ZDATETIME_PYARROW_DTYPESr  r  r  r   r  r  r   r  r  r  r  r  r
  r  r  r  r  r  r,   r,   r,   r-   <module>   s  ($	

;


:


>P D'A  5+ "
L



 
		





	

	
 




*



















("		
	


	

						