o
    ҷh/                     @   s  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
 d dlmZmZm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ZG dd dee
jZG dd dee
jZG dd dee
jZG dd dee
jZG dd dee
j Z!G dd dee
j"Z#G d d! d!ee
j$Z%ej&j'd"d#Z(G d$d% d%e
j)Z*G d&d' d'ee
j+Z,G d(d) d)ee
j-Z.G d*d+ d+ee
j/Z0G d,d- d-ee
j1Z2G d.d/ d/ee
j3Z4G d0d1 d1ee
j5Z6d2d3 Z7d4d5 Z8d6d7 Z9dS )8    N)base)	JSONArray	JSONDtype	make_datac                   C   s   t  S N)r    r   r   X/var/www/html/venv/lib/python3.10/site-packages/pandas/tests/extension/json/test_json.pydtype      r	   c                  C   sD   t  } t| d t| d krt  } t| d t| d kst| S )z*Length-100 PeriodArray for semantics test.r      )r   lenr   )datar   r   r   r      s
   r   c                   C   s   t i ddigS )zLength 2 array with [NA, Valid]a
   r   r   r   r   r   data_missing'      r   c                   C   s   t ddiddidddgS )Nbr   c         r   r   r   r   r   r   r   data_for_sorting-   s   r   c                   C   s   t ddii ddigS )Nr   r   r   r   r   r   r   r   r   data_missing_for_sorting2   s   r   c                   C   s   t jS r   )operatoreqr   r   r   r   na_cmp7   r
   r   c                
   C   s4   t ddiddii i ddddddddiddigS )Nr   r   r   r   r   r   r   r   r   r   r   data_for_grouping<   s   r   c                   @      e Zd ZdS )BaseJSONN__name__
__module____qualname__r   r   r   r   r    L       r    c                   @   r   )	TestDtypeNr!   r   r   r   r   r&   P   r%   r&   c                       *   e Zd Zejjdd fddZ  ZS )TestInterfacez:comparison method not implemented for JSONArray (GH-37867)reasonc                       t  | d S r   )supertest_containsselfr   	__class__r   r   r-   U   s   zTestInterface.test_contains)r"   r#   r$   pytestmarkxfailr-   __classcell__r   r   r0   r   r(   T   s
    r(   c                       sx   e Zd Zejjdd fddZejjdd fddZejjdd fdd	Zejjd
d fddZ	  Z
S )TestConstructorsz&not implemented constructor from dtyper)   c                    r+   r   )r,   test_from_dtyper.   r0   r   r   r7   ^   r   z TestConstructors.test_from_dtypezRecursionError, GH-33900c              	      >   t  }zt d t || W t | d S t | w Nd   )sysgetrecursionlimitsetrecursionlimitr,   *test_series_constructor_no_data_with_indexr/   r	   na_value	rec_limitr0   r   r   r>   c   
   
z;TestConstructors.test_series_constructor_no_data_with_indexc              	      r8   r9   )r;   r<   r=   r,   ,test_series_constructor_scalar_na_with_indexr?   r0   r   r   rC   n   rB   z=TestConstructors.test_series_constructor_scalar_na_with_indexzcollection as scalar, GH-33901c              	      r8   r9   )r;   r<   r=   r,   )test_series_constructor_scalar_with_index)r/   r   r	   rA   r0   r   r   rD   y   rB   z:TestConstructors.test_series_constructor_scalar_with_index)r"   r#   r$   r2   r3   r4   r7   r>   rC   rD   r5   r   r   r0   r   r6   ]   s    

r6   c                       sD   e Zd Zejjdd fddZejjdd fddZ  ZS )TestReshapingzDifferent definitions of NAr)   c                       t    dS )z
        The test does .astype(object).stack(future_stack=True). If we happen to have
        any missing values in `data`, then we'll end up with different
        rows since we consider `{}` NA, but `.astype(object)` doesn't.
        N)r,   
test_stackr/   r0   r   r   rG      s   zTestReshaping.test_stackzdict for NAc                    s   t  ||S r   )r,   test_unstack)r/   r   indexr0   r   r   rI      s   zTestReshaping.test_unstack)	r"   r#   r$   r2   r3   r4   rG   rI   r5   r   r   r0   r   rE      s
    rE   c                   @   r   )TestGetitemNr!   r   r   r   r   rK      r%   rK   c                   @   r   )	TestIndexNr!   r   r   r   r   rL      r%   rL   c                       sD   e Zd Zejjdd fddZejjdd fddZ  ZS )TestMissingzSetting a dict as a scalarr)   c                    rF   z;We treat dictionaries as a mapping in fillna, not a scalar.N)r,   test_fillna_seriesrH   r0   r   r   rO         zTestMissing.test_fillna_seriesc                    rF   rN   )r,   test_fillna_framerH   r0   r   r   rQ      rP   zTestMissing.test_fillna_frame)	r"   r#   r$   r2   r3   r4   rO   rQ   r5   r   r   r0   r   rM      s
    rM   
Unhashabler)   c                   @   r   )
TestReduceNr!   r   r   r   r   rS      r%   rS   c                       s&  e Zd Ze fddZe fddZe fddZej	ddd	g fd
dZ
ej	ddd	g fddZejjdd fddZejjdd	ed fddZejjdd fddZejjdd fddZejjdd fddZejd fdd Z fd!d"Z  ZS )#TestMethodsc                       t  || d S r   )r,   test_value_counts)r/   all_datadropnar0   r   r   rV      s   zTestMethods.test_value_countsc                    r+   r   )r,    test_value_counts_with_normalizer.   r0   r   r   rY         z,TestMethods.test_value_counts_with_normalizec                    s   t    d S r   )r,   test_sort_values_framerH   r0   r   r   r[      rP   z"TestMethods.test_sort_values_frame	ascendingTFc                       t  ||| d S r   )r,   test_sort_values)r/   r   r\   sort_by_keyr0   r   r   r^         zTestMethods.test_sort_valuesc                    r]   r   )r,   test_sort_values_missing)r/   r   r\   r_   r0   r   r   ra      s   z$TestMethods.test_sort_values_missingz#combine for JSONArray not supportedr)   c                    r+   r   )r,   test_combine_le)r/   data_repeatedr0   r   r   rb      rZ   zTestMethods.test_combine_lezGcombine for JSONArray not supported - may pass depending on random data)r*   strictraisesc                    r+   r   )r,   test_combine_firstr.   r0   r   r   rf      s   zTestMethods.test_combine_firstzbroadcasting errorc                    rU   r   )r,   test_where_series)r/   r   r@   r0   r   r   rg      s   zTestMethods.test_where_serieszCan't compare dicts.c                    r+   r   )r,   test_searchsorted)r/   r   r0   r   r   rh      rZ   zTestMethods.test_searchsortedc                    r]   r   )r,   test_equals)r/   r   r@   	as_seriesr0   r   r   ri      r`   zTestMethods.test_equalsz-fill-value is interpreted as a dict of valuesc                    r+   r   )r,   test_fillna_copy_frame)r/   r   r0   r   r   rk      rZ   z"TestMethods.test_fillna_copy_framec                    s.   |rt jjdd}|j| t | d S )NzFails with CoWr)   )r2   r3   r4   node
add_markerr,   &test_equals_same_data_different_object)r/   r   using_copy_on_writerequestr3   r0   r   r   rn      s   z2TestMethods.test_equals_same_data_different_object)r"   r#   r$   
unhashablerV   rY   r[   r2   r3   parametrizer^   ra   r4   rb   AssertionErrorrf   rg   rh   ri   skiprk   rn   r5   r   r   r0   r   rT      s8    
rT   c                       r'   )TestCastingz$failing on np.array(self, dtype=str)r)   c                    rF   )zThis currently fails in NumPy on np.array(self, dtype=str) with

        *** ValueError: setting an array element with a sequence
        N)r,   test_astype_strrH   r0   r   r   rv         zTestCasting.test_astype_str)r"   r#   r$   r2   r3   r4   rv   r5   r   r   r0   r   ru      s    ru   c                       sP   e Zd Ze fddZe fddZe fddZe fddZ  ZS )	TestGroupbyc                    rF   )a  
        This currently fails in Series.name.setter, since the
        name must be hashable, but the value is a dictionary.
        I think this is what we want, i.e. `.name` should be the original
        values, and not the values for factorization.
        N)r,    test_groupby_extension_transformrH   r0   r   r   ry     s   z,TestGroupby.test_groupby_extension_transformc                    rF   )z
        This fails in Index._do_unique_check with

        >   hash(val)
        E   TypeError: unhashable type: 'UserDict' with

        I suspect that once we support Index[ExtensionArray],
        we'll be able to dispatch unique.
        N)r,   test_groupby_extension_applyrH   r0   r   r   rz     s   z(TestGroupby.test_groupby_extension_applyc                    rF   z
        This fails when we get to tm.assert_series_equal when left.index
        contains dictionaries, which are not hashable.
        N)r,   test_groupby_extension_aggrH   r0   r   r   r|     rw   z&TestGroupby.test_groupby_extension_aggc                    rF   r{   )r,   test_groupby_extension_no_sortrH   r0   r   r   r}   "  rw   z*TestGroupby.test_groupby_extension_no_sort)	r"   r#   r$   rq   ry   rz   r|   r}   r5   r   r   r0   r   rx     s    	rx   c                          e Zd Z fddZ  ZS )TestArithmeticOpsc                    s<   t |d dkrtjjdd}|j| t || d S )Nr   r   zraises in coercing to Seriesr)   )r   r2   r3   r4   rl   rm   r,   test_arith_frame_with_scalar)r/   r   all_arithmetic_operatorsrp   r3   r0   r   r   r   ,  s   z.TestArithmeticOps.test_arith_frame_with_scalar)r"   r#   r$   r   r5   r   r   r0   r   r   +      r   c                       r~   )TestComparisonOpsc                    s6   |j dv rtjjdd}|j| t || d S )N)r   nez"Comparison methods not implementedr)   )r"   r2   r3   r4   rl   rm   r,   test_compare_array)r/   r   comparison_oprp   r3   r0   r   r   r   4  s   
z$TestComparisonOps.test_compare_array)r"   r#   r$   r   r5   r   r   r0   r   r   3  r   r   c                   @   r   )TestPrintingNr!   r   r   r   r   r   ;  r%   r   c                 O   sz   | j jdkr.| j |j ksJ tjt| jt| j| jd} tjt|jt|j|jd}t	j
| |g|R i | d S )Njson)rJ   name)r	   r   pdSeriesr   valuesastypeobjectrJ   tmassert_series_equal)leftrightargskwargsr   r   r   custom_assert_series_equal?  s   r   c              
   O   s   | dd}tj| j|j| dd| dd| dd| d	d| d
d | jdkj}|D ]}t| | || g|R i | q/| j|d} |j|d}tj| |g|R i | d S )Nobj	DataFramecheck_column_typeequivcheck_namesTcheck_exactFcheck_categoricalz.columns)exactr   r   r   r   r   )columns)	getr   assert_index_equalr   dtypesrJ   r   dropassert_frame_equal)r   r   r   r   obj_typejsonscolr   r   r   custom_assert_frame_equalQ  s    




"r   c                  C   s   t tdditdditddig} t| }t|| t| |  t| g d}d}t	j
t|d	 t|| W d    n1 sLw   Y  t	j
t|d	 t| |  W d    d S 1 smw   Y  d S )
Nr   r   r   r   r   r   )r   r   r   zSeries are different)match)r   collectionsUserDictr   r   r   r   to_frametaker2   re   rs   )r   r   r   msgr   r   r   test_custom_assertsg  s"   

"r   ):r   r   r;   r2   pandasr   pandas._testing_testingr   pandas.tests.extensionr   !pandas.tests.extension.json.arrayr   r   r   fixturer	   r   r   r   r   r   r   r    BaseDtypeTestsr&   BaseInterfaceTestsr(   BaseConstructorsTestsr6   BaseReshapingTestsrE   BaseGetitemTestsrK   BaseIndexTestsrL   BaseMissingTestsrM   r3   r4   rq   BaseReduceTestsrS   BaseMethodsTestsrT   BaseCastingTestsru   BaseGroupbyTestsrx   BaseArithmeticOpsTestsr   BaseComparisonOpsTestsr   BasePrintingTestsr   r   r   r   r   r   r   r   <module>   sR    






	(C)