
    hH                     j   d Z ddlZddlZddlZddlZddlmZ ddl	m
Z ddlZddlmZ ddlmZmZ ddlmZmZmZ ddlZddlmZmZ ej4                  j7                  d	
      Zej4                  j7                  d
      Zej<                  d        Zd Z ej<                  d        Z!ej<                  d        Z"ej<                  d        Z# ej<                  ddg      d        Z$ej<                  d        Z%ej<                  d        Z&ej<                  d        Z'ej<                  d        Z(ej<                  d        Z)ej<                  d        Z* ej<                  ddg      d        Z+ ej<                  d d d  d! gg d"#      d$        Z, ej<                  ddg      d%        Z- ej<                  ddg      d&        Z. ej<                  ddg      d'        Z/ ej<                  d(d)g      d*        Z0 ej<                  ddg      d+        Z1ej<                  d,        Z2 ej<                  g d-      d.        Z3 ej<                  d/d0g      d1        Z4 ej<                  d2d3g      d4        Z5 ej<                  dd5 g      d6        Z6 G d7 d8ejn                        Z8 G d9 d:ejr                        Z: G d; d<ejv                        Z< G d= d>ejz                        Z> G d? d@ej~                        Z@ G dA dBej                        ZB G dC dDej                        ZDerddElEmFZF nddFlEmGZF  G dG dHeF      ZHg dIZI ej<                  eI      dJ        ZJej4                  j                  dK       G dL dMej                               ZMej4                  j                  dK       G dN dOej                               ZO G dP dQej                        ZQ G dR dSej                        ZS G dT dUej                        ZU G dV dWej                        ZWe G dX dYej                               ZYy)Zaw  
This file contains a minimal set of tests for compliance with the extension
array interface test suite (by inheriting the pandas test suite), and should
contain no other tests.
Other tests (eg related to the spatial functionality or integration
with GeoSeries/GeoDataFrame) should be added to test_array.py and others.

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).

A set of fixtures are defined to provide data for the tests (the fixtures
expected to be available to pytest by the inherited pandas tests).

    Nis_object_dtype)base)Point)PANDAS_GE_21PANDAS_GE_22)GeometryArrayGeometryDtypefrom_shapely)assert_frame_equalassert_series_equalzNot yet implementedreasonzMin/max not supportedc                      t               S )z3A fixture providing the ExtensionDtype to validate.)r
        W/var/www/html/immo/lib/python3.12/site-packages/geopandas/tests/test_extension_array.pydtyper   0   s     ?r   c                      t        j                  dt              } t        d      D cg c]"  }t        j
                  j                  ||      $ c}| d d  t        |       }|S c c}w )Nd   r   )npemptyobjectrangeshapelygeometryr   r   )aigas      r   	make_datar!   6   sP    
F#A27*=QG""1a(=AaD	aBI >s   'A#c                      t               S )zLength-100 array for this type.

    * data[0] and data[1] should both be non missing
    * data[0] and data[1] should not be equal
    )r!   r   r   r   datar#   =   s     ;r   c                      t         )z3Length-100 array in which all the elements are two.)NotImplementedErrorr   r   r   data_for_twosr&   G   s
     r   c                  X    t        dt        j                  j                  dd      g      S )zLength-2 array with [NA, Valid]N   r   r   r   r   r   r   r   data_missingr*   M   s'     w//55a;<==r   r#   r*   )paramsc                 H    | j                   dk(  r|S | j                   dk(  r|S y)z5Parametrized fixture giving 'data' and 'data_missing'r#   r*   Nparam)requestr#   r*   s      r   all_datar0   S   s,     }}	.	( 
)r   c                       fd}|S )a  
    Generate many datasets.

    Parameters
    ----------
    data : fixture implementing `data`

    Returns
    -------
    Callable[[int], Generator]:
        A callable that takes a `count` argument and
        returns a generator yielding `count` datasets.
    c              3   6   K   t        |       D ]  }  y wN)r   )count_r#   s     r   genzdata_repeated.<locals>.genl   s     u 	AJ	s   r   )r#   r6   s   ` r   data_repeatedr7   \   s      Jr   c                  Z    t        t        dd      t        dd      t        dd      g      S )ziLength-3 array with a known sort order.

    This should be three items [B, C, A] with
    A < B < C
    r   r(   r   r   r   r   r   data_for_sortingr:   s   s(     q!eAqk5A;?@@r   c                  F    t        t        dd      dt        dd      g      S )zvLength-3 array with a known sort order.

    This should be three items [B, NA, A] with
    A < B and NA missing.
    r(      Nr   r9   r   r   r   data_missing_for_sortingr=   }   s"     q!dE!QK899r   c                      d S )zBinary operator for comparing NA values.
    Should return a function of two arguments that returns
    True if both arguments are (scalar) NA for your type.
    By default, uses ``operator.or``
    c                     | d u xr |d u S r3   r   )xys     r   <lambda>zna_cmp.<locals>.<lambda>   s    T	/a4i r   r   r   r   r   na_cmprC      s
     0/r   c                       y)z6The scalar missing value for this type. Default 'None'Nr   r   r   r   na_valuerE      s     r   c                     t        t        j                  j                  dd      t        j                  j                  dd      ddt        j                  j                  dd      t        j                  j                  dd      t        j                  j                  dd      t        j                  j                  dd      g      S )zData 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
    r(   Nr   r<   r)   r   r   r   data_for_groupingrG      s     ""1a(""1a(""1a(""1a(""1a(""1a(		
 r   TFc                     | j                   S )z#Whether to box the data in a Seriesr-   r/   s    r   box_in_seriesrJ      s     ==r   c                      yNr(   r   r@   s    r   rB   rB          r   c                      dgt        |       z  S rL   lenrM   s    r   rB   rB      s    1#A, r   c                 F    t        j                  dgt        |       z        S rL   pdSeriesrQ   rM   s    r   rB   rB      s    "))QC#a&L) r   c                     | S r3   r   rM   s    r   rB   rB      s    ! r   scalarlistseriesr   )r+   idsc                     | j                   S )z,
    Functions to test groupby.apply().
    r-   rI   s    r   groupby_apply_opr]      s     ==r   c                     | j                   S )zU
    Boolean fixture to support Series and Series.to_frame() comparison testing.
    r-   rI   s    r   as_framer_          
 ==r   c                     | j                   S )zL
    Boolean fixture to support arr and Series(arr) comparison testing.
    r-   rI   s    r   	as_seriesrb      r`   r   c                     | j                   S )zd
    Boolean fixture to support comparison testing of ExtensionDtype array
    and numpy array.
    r-   rI   s    r   	use_numpyrd           ==r   ffillbfillc                     | j                   S )z{
    Parametrized fixture giving method parameters 'ffill' and 'bfill' for
    Series.fillna(method=<method>) testing.
    r-   rI   s    r   fillna_methodri      re   r   c                     | j                   S )zR
    Boolean fixture to support ExtensionDtype _from_sequence method testing.
    r-   rI   s    r   as_arrayrk      r`   r   c                 4    t         j                  t               S )z
    A scalar that *cannot* be held by this ExtensionArray.

    The default should work for most subclasses, but is not guaranteed.

    If the array can hold any item (i.e. object dtype), then use pytest.skip.
    )r   __new__)r#   s    r   invalid_scalarrn      s     >>&!!r   )
summaxminmeanprodstdvarmediankurtskewc                     | j                   S )z-
    Fixture for numeric reduction names
    r-   rI   s    r   all_numeric_reductionsrz           ==r   allanyc                     | j                   S )z-
    Fixture for boolean reduction names
    r-   rI   s    r   all_boolean_reductionsr     r`   r   __eq____ne__c                     | j                   S )zu
    Fixture for dunder names for common compare operations

    * >=
    * >
    * ==
    * !=
    * <
    * <=
    r-   rI   s    r   all_compare_operatorsr     s     ==r   c                     | S r3   r   rM   s    r   rB   rB      s     r   c                     | j                   S )zk
    Simple fixture for testing keys in sorting methods.
    Tests None (no key) and the identity key.
    r-   rI   s    r   sort_by_keyr      re   r   c                       e Zd Zd Zd Zy)	TestDtypec                 4    |j                         t        u sJ y r3   )construct_array_typer	   )selfr#   r   s      r   test_array_type_with_argz"TestDtype.test_array_type_with_arg1  s    ))+}<<<r   c                     t        j                  t        j                  |      t              }|j                  d      }t        |j                  t              sJ t        j                  |      }t        ||       y )Nr   r   )
rT   rU   r   asarrayr   astype
isinstancearrayr	   r   )r   r#   r   sresultexpecteds         r   test_registryzTestDtype.test_registry4  sT    IIbjj&f5*%&,,66699T?FH-r   N)__name__
__module____qualname__r   r   r   r   r   r   r   .  s    =.r   r   c                       e Zd Zd Zy)TestInterfacec                     ||j                             }|d   |v sJ |d   |v sJ d |v sJ d |vsJ t        j                  |vsJ y Nr   )isnarT   NaT)r   r#   r*   s      r   test_containszTestInterface.test_contains=  sh     TYY[L! Aw$A,...|###4vv\)))r   N)r   r   r   r   r   r   r   r   r   <  s    *r   r   c                       e Zd Zy)TestConstructorsNr   r   r   r   r   r   r   r   N      r   r   c            
          e Zd Zej                  j                  dej                  j                  ddgddggddg      ej                  j                  g d      ej                  j                  g d      ej                  j                  g d	      g      ej                  j                  d
ddg      d               Z
y)TestReshapingindexABr   b)names))r   r   )r   r   )r   r   )r   r   )r   r   c)r   r(   r<   ))r   r   r(   )r   r   r   )r   r   r   )r   r   r   )r   r   r(   objrZ   framec                 ^   d t        |       |dk(  rt        j                  |      }nt        j                  d|      }|j                  }t        t        |            t        j                  j                  fdt        d|      D              }|D ]  }|j                  |      t        fdj                  D              sJ |dk(  r?|j                         }|j                  |      j                  dd	      }	t        |	       |j!                  t"              }
|
j                  |j$                  j&                  
      }|dk(  rt        d |j(                  D              sJ d ||j+                         <   j!                  t"              t        |        y )NrZ   r   r   c              3   J   K   | ]  }t        j                  |        y wr3   )	itertoolspermutations).0r   levelss     r   	<genexpr>z-TestReshaping.test_unstack.<locals>.<genexpr>z  s#      5
23I""61-5
s    #r(   )levelc              3   b   K   | ]&  }t        |   j                  t                     ( y wr3   )r   r   type)r   colr#   r   s     r   r   z-TestReshaping.test_unstack.<locals>.<genexpr>  s+      >A
6#;,,d4j9s   ,/r   )axis)r   
fill_valuec              3   2   K   | ]  }t        |        y wr3   r   )r   r@   s     r   r   z-TestReshaping.test_unstack.<locals>.<genexpr>  s     G!?1-Gs   )rQ   rT   rU   	DataFramenlevelsrY   r   r   chainfrom_iterableunstackr|   columnsto_frame	droplevelr   r   r   r   rE   dtypesr   )r   r#   r   r   serncombinationsr   dfaltobj_serr   r   r   s    `          @@r   test_unstackzTestReshaping.test_unstackZ  su   , Lc%j!(?))D.C,,T5UCCMMeAh !44 5
7<Q{5
 
 " 	1E[[u[-F EK^^    h\\^jjuj-777B"63/jj(GUtzz?R?RSHhGxGGGG(,HX]]_% ]]6*Fvx0/	1r   N)r   r   r   pytestmarkparametrizerT   
MultiIndexfrom_productfrom_tuplesr   r   r   r   r   r   R  s     [[ MM&&#sc3Z(@#s&TMM%%&JKMM&&'OPMM%%	
( [[UXw$78&1 9)*&1r   r   c                       e Zd Zy)TestGetitemNr   r   r   r   r   r     r   r   r   c                       e Zd Zy)TestSetitemNr   r   r   r   r   r     r   r   r   c                   J    e Zd Zd Zej
                  j                  e d       fd       Zej
                  j                  e d       fd       Z	ej
                  j                  e d       fd       Z
ej
                  j                  e d       fd       Z xZS )TestMissingc           	         |d   }t        j                  |      }|j                  |      }t        j                  |j                  ||g            }t	        ||       t        j                  t        t        j                  j                  dd      t        j                  j                  dd      g            }|j                  |      }t        j                  |j                  ||g            }t	        ||       t        j                  t        t        j                  j                  dd      t        j                  j                  dd      g      ddg      }|j                  |      }t	        ||       y )Nr(   r<   
      r   )	rT   rU   fillna_from_sequencer   r   r   r   r   )r   r*   r   r   r   r   fillers          r   test_fillna_serieszTestMissing.test_fillna_series  s>   !!_
ii% J'99\88*j9QRSFH- $$**1a0$$**1a0
 F#99\88*j9QRSFH- $$**1a0$$**1a0 r(
 F#FC(r   z-fillna method not supported with older pandasr   c                 $    t         |   |       y r3   )supertest_fillna_limit_padr   r*   	__class__s     r   r   z!TestMissing.test_fillna_limit_pad  s     	%l3r   c                 $    t         |   |       y r3   )r   test_fillna_limit_backfillr   s     r   r   z&TestMissing.test_fillna_limit_backfill  s     	*<8r   c                 &    t         |   ||       y r3   )r   test_fillna_series_method)r   r*   ri   r   s      r   r   z%TestMissing.test_fillna_series_method  s     	),Fr   c                 $    t         |   |       y r3   )r   test_fillna_no_op_returns_copy)r   r#   r   s     r   r   z*TestMissing.test_fillna_no_op_returns_copy  s     	.t4r   )r   r   r   r   r   r   skipifr   r   r   r   r   __classcell__r   s   @r   r   r     s    !)N [[!P  44 [[!P  99 [[!P  GG [[!P  55r   r   )BaseReduceTests)BaseNoReduceTestsc                   N    e Zd Zej                  j                  d      d        Zy)
TestReducez6boolean reduce (any/all) tested in test_pandas_methodsc                      y r3   r   r   s    r   test_reduce_series_booleanz%TestReduce.test_reduce_series_boolean      r   N)r   r   r   r   r   skipr   r   r   r   r   r     s%    [[NO Pr   r   )__add____radd____mul____rmul____floordiv____rfloordiv____truediv____rtruediv____pow____rpow____mod____rmod__c                     | j                   S )z
    Fixture for dunder names for common arithmetic operations

    Adapted to exclude __sub__, as this is implemented as "difference".
    r-   rI   s    r   all_arithmetic_operatorsr    r{   r   zOignore:The array interface is deprecated and will no longer work in Shapely 2.0c                       e Zd Zej                  j                  d      d        Zej                  j                  d      d        Zy)TestArithmeticOpsznot applicabler   c                      y r3   r   )r   r#   r&   s      r   test_divmod_series_arrayz*TestArithmeticOps.test_divmod_series_array  r   r   c                      y r3   r   r   r#   s     r   $test_add_series_with_extension_arrayz6TestArithmeticOps.test_add_series_with_extension_array  r   r   N)r   r   r   r   r   r   r	  r  r   r   r   r  r  
  sP     [[-. / [[-. /r   r  c                       e Zd Zd Zd Zd Zy)TestComparisonOpsc                     t        t        |j                  d            } |||      }|j                  ||      }t	        ||       y )Nr5   )getattroperatorstripcombiner   )r   r   r#   op_nameotheropr   r   s           r   _compare_otherz TestComparisonOps._compare_other  s<    Xw}}S12Au99UB'FH-r   c                 `    |}t        j                  |      }| j                  ||||d          y r   )rT   rU   r  )r   r#   r   r  r   s        r   test_compare_scalarz%TestComparisonOps.test_compare_scalar#  s,    'IIdOAtWd1g6r   c                     |}t        j                  |      }t        j                  |d   gt        |      z        }| j                  ||||       y r   )rT   rU   rQ   r  )r   r#   r   r  r   r  s         r   test_compare_arrayz$TestComparisonOps.test_compare_array(  sE    'IIdO		47)c$i/0AtWe4r   N)r   r   r   r  r  r  r   r   r   r  r    s    .7
5r   r  c                       e Zd Zej                  j                  dddg      d        Zd Zej                  j                  dddg       fd       Zej                  j                  d	      d
        Z
ed        Zej                  j                  d	      d        Zed        Zed        Zed        Zed        Zed        Zed        Z xZS )TestMethodsdropnaTFc                      y r3   r   )r   r0   r  s      r   test_value_countszTestMethods.test_value_counts0  r   r   c                      y r3   r   r  s     r    test_value_counts_with_normalizez,TestMethods.test_value_counts_with_normalize4  s    r   	ascendingc                 &    t         |   ||       y r3   )r   test_sort_values_frame)r   r:   r#  r   s      r   r%  z"TestMethods.test_sort_values_frame7  s    &'7Cr   zsearchsorted not supportedr   c                      y r3   r   )r   r:   rb   s      r   test_searchsortedzTestMethods.test_searchsorted;  r   r   c                      y r3   r   r   s    r   test_combine_lezTestMethods.test_combine_le?  r   r   zaddition not supportedc                      y r3   r   r   s    r   test_combine_addzTestMethods.test_combine_addC  r   r   c                     d}t        j                  t        |      5  |j                  |j	                  dg             d d d        y # 1 sw Y   y xY w)Nz!Length of 'value' does not match.)matchr(   )r   raises
ValueErrorr   take)r   r*   msgs      r   test_fillna_length_mismatchz'TestMethods.test_fillna_length_mismatchG  sE    1]]:S1 	8 1 11# 67	8 	8 	8s   "A		Ac                      y r3   r   r   s    r   test_argmin_argmaxzTestMethods.test_argmin_argmaxM  r   r   c                      y r3   r   r   s    r   test_argmin_argmax_empty_arrayz*TestMethods.test_argmin_argmax_empty_arrayQ  r   r   c                      y r3   r   r   s    r   test_argmin_argmax_all_naz%TestMethods.test_argmin_argmax_all_naU  r   r   c                      y r3   r   r   s    r   test_argreduce_seriesz!TestMethods.test_argreduce_seriesY  r   r   c                      y r3   r   r   s    r   +test_argmax_argmin_no_skipna_notimplementedz7TestMethods.test_argmax_argmin_no_skipna_notimplemented]  r   r   )r   r   r   r   r   r   r   r"  r%  r   r'  not_yet_implementedr)  r+  r2  	no_minmaxr4  r6  r8  r:  r<  r   r   s   @r   r  r  /  s4   [[Xe}5 6 [[[4-8D 9D [[9: ;   [[56 7 8 8
          r   r  c                       e Zd Zy)TestCastingNr   r   r   r   r@  r@  b  r   r   r@  c                        e Zd Zej                  j                  dddg       fd       Z fdZej                  j                  dd d d	 d
 gg d       fd       Z xZ	S )TestGroupbyas_indexTFc                 &    t         |   ||       y r3   )r   test_groupby_extension_agg)r   rC  rG   r   s      r   rE  z&TestGroupby.test_groupby_extension_aggg  s    *85FGr   c                 $    t         |   |       y r3   )r    test_groupby_extension_transform)r   rG   r   s     r   rG  z,TestGroupby.test_groupby_extension_transformk  s    01BCr   r  c                      yrL   r   rM   s    r   rB   zTestGroupby.<lambda>q  rN   r   c                      dgt        |       z  S rL   rP   rM   s    r   rB   zTestGroupby.<lambda>r  s    qcCFl r   c                 F    t        j                  dgt        |       z        S rL   rS   rM   s    r   rB   zTestGroupby.<lambda>s  s    biic!f- r   c                     | S r3   r   rM   s    r   rB   zTestGroupby.<lambda>t  s    a r   rW   )r[   c                 &    t         |   ||       y r3   )r   test_groupby_extension_apply)r   rG   r  r   s      r   rM  z(TestGroupby.test_groupby_extension_applyn  s     	,->Cr   )
r   r   r   r   r   r   rE  rG  rM  r   r   s   @r   rB  rB  f  su    [[Z$7H 8HD [["-		
 3  	D	Dr   rB  c                       e Zd Zy)TestPrintingNr   r   r   r   rO  rO  |  r   r   rO  c                       e Zd Zy)TestParsingNr   r   r   r   rQ  rQ    s    r   rQ  )Z__doc__r   r  numpyr   pandasrT   pandas.api.typesr   pandas.tests.extensionr   extension_testsshapely.geometryr   r   geopandas._compatr   r   geopandas.arrayr	   r
   r   r   pandas.testingr   r   r   r   r=  r>  fixturer   r!   r#   r&   r*   r0   r7   r:   r=   rC   rE   rG   rJ   r]   r_   rb   rd   ri   rk   rn   rz   r   r   r   BaseDtypeTestsr   BaseInterfaceTestsr   BaseConstructorsTestsr   BaseReshapingTestsr   BaseGetitemTestsr   BaseSetitemTestsr   BaseMissingTestsr   pandas.tests.extension.baser   r   r   _all_arithmetic_operatorsr  filterwarningsBaseArithmeticOpsTestsr  BaseComparisonOpsTestsr  BaseMethodsTestsr  BaseCastingTestsr@  BaseGroupbyTestsrB  BasePrintingTestsrO  BaseParsingTestsrQ  r   r   r   <module>rn     s        , :  " 8 F F  B kk&&.C&D KK$;<	  
    
 > >
 /0 1  , A A : : 0 0  
  * e}% &
 )	 	/ e}% & e}% & e}% & )* + e}% & " " X u~& ' (+, - k*+ ,... .*O66 *$	<< 	C1O66 C1L	/22 		/22 	>5/22 >5B ;P  " 01 2 U>>  U5>> 55&0/22 0f	/22 	D/22 D,	?44 	 	/22 	 	r   