
    h@+                         d Z ddlZddlZddlmZmZ ddlmZ d Z	d Z
d Zd Zd	 Z	 	 	 	 	 	 	 dd
Zd Zd Z	 	 	 	 	 	 	 	 	 ddZy)z,Testing functionality for geopandas objects.    N)GeoDataFrame	GeoSeries)GeometryDtypec                 J   t        j                         5  t        j                  ddt               t	        | d      r| j                         cddd       S t	        | d      r| j                         cddd       S t        j                  |       cddd       S # 1 sw Y   yxY w)z<Version of isna that works for both scalars and (Geo)Series.ignorez&GeoSeries.isna\(\) previously returnedisnaNisnull)warningscatch_warningsfilterwarningsUserWarninghasattrr   r	   pd)thiss    D/var/www/html/immo/lib/python3.12/site-packages/geopandas/testing.py_isnar      s    		 	 	" #
 	?	
 4 99;# # T8$;;=# # 99T?# # #s   7BB;BB"c                     | j                  |      | j                  |j                  z  z  t        |       t        |      z  z  S )aS  
    Test for geometric equality. Empty or missing geometries are considered
    equal.

    Parameters
    ----------
    this, that : arrays of Geo objects (or anything that has an `is_empty`
                 attribute)

    Returns
    -------
    Series
        boolean Series, True if geometries in left equal geometries in right
    )geom_equalsis_emptyr   r   thats     r   _geom_equals_maskr      sA      	==4==(	*;t$	&    c                 6    t        | |      j                         S )aE  
    Test for geometric equality. Empty or missing geometries are considered
    equal.

    Parameters
    ----------
    this, that : arrays of Geo objects (or anything that has an `is_empty`
                 attribute)

    Returns
    -------
    bool
        True if all geometries in left equal geometries in right
    )r   allr   s     r   r   r   3   s     T4(,,..r   c                     | j                  |d      | j                  |j                  z  z  t        |       t        |      z  z  S )a  
    Test for 'almost' geometric equality. Empty or missing geometries
    considered equal.

    This method allows small difference in the coordinates, but this
    requires coordinates be in the same order for all components of a geometry.

    Parameters
    ----------
    this, that : arrays of Geo objects

    Returns
    -------
    Series
        boolean Series, True if geometries in left almost equal geometries in right
    gƠ>)	tolerance)geom_equals_exactr   r   r   s     r   _geom_almost_equals_maskr   E   sG    $ 	t/?@==4==(	*;t$	&r   c                     t        | t              r(t        |t              r| j                  } |j                  }t        | |      j	                         S )a  
    Test for 'almost' geometric equality. Empty or missing geometries
    considered equal.

    This method allows small difference in the coordinates, but this
    requires coordinates be in the same order for all components of a geometry.

    Parameters
    ----------
    this, that : arrays of Geo objects (or anything that has an `is_empty`
                 property)

    Returns
    -------
    bool
        True if all geometries in left almost equal geometries in right
    )
isinstancer   geometryr   r   r   s     r   geom_almost_equalsr#   ]   s?    $ $%*T<*H}}}}#D$/3355r   c	                 >   t        |       t        |      k(  sJ t        |        dt        |              |rvd}	t        | j                  t              s J |	j	                  | j                               t        |j                  t              s J |	j	                  | j                               |r+t        | j
                  t        |j
                              sJ |rFt        | t              sJ t        | t        |            sJ |r]| j                  |j                  k(  sDJ t        | t              st        |       } t        |t              st        || j
                        }| j
                  j                  |j
                        s!J d| j
                   d|j
                          |rH| j                  |j                  k(  j                         s!J d| j                   d|j                          |rFt        | j                  j                               } t        |j                  j                               }|sFt        j                         5  t        j                   ddt"               t%        | ||       ddd       yt%        | ||       y# 1 sw Y   yxY w)	ar  
    Test util for checking that two GeoSeries are equal.

    Parameters
    ----------
    left, right : two GeoSeries
    check_dtype : bool, default False
        If True, check geo dtype [only included so it's a drop-in replacement
        for assert_series_equal].
    check_index_type : bool, default False
        Check that index types are equal.
    check_series_type : bool, default True
        Check that both are same type (*and* are GeoSeries). If False,
        will attempt to convert both into GeoSeries.
    check_less_precise : bool, default False
        If True, use geom_equals_exact with relative error of 0.5e-6.
        If False, use geom_equals.
    check_geom_type : bool, default False
        If True, check that all the geom types are equal.
    check_crs: bool, default True
        If `check_series_type` is True, then also check that the
        crs matches.
    normalize: bool, default False
        If True, normalize the geometries before comparing equality.
        Typically useful with ``check_less_precise=True``, which uses
        ``geom_equals_exact`` and requires exact coordinate order.
    z != z(dtype should be a GeometryDtype, got {0})indexzindex: ztype: r   zCRS mismatchN)lenr!   dtyper   formatr%   typer   crsequals	geom_typer   array	normalizer
   r   r   r   _check_equality)
leftrightcheck_dtypecheck_index_typecheck_series_typecheck_less_precisecheck_geom_type	check_crsr.   msgs
             r   assert_geoseries_equalr9   v   s   L t9E
"Bs4ykc%j\$BB"8$**m4Lcjj6LL4%++}5Mszz$**7MM5$**d5;;&7888$	***$U,,,88uyy((($	*T?D%+e4::6E::U[[)RWTZZLU[[M+RR)%//1668 	
T^^$D(9:	
8 --/0%++//12$$& 	=##HnkJD%);<	= 	= 	e%78		= 	=s   )JJc                 H    t        |       }t        |      dkD  r|dd dz   S |S )zTruncate WKT repr of geom.d   Nz...)strr&   )geomss     r   _truncated_stringr?      s+    D	A
1v|#wr   c                 h   d}|rd}t        | |      }nd}t        | |      }|j                         s| |    }||    }t        |j	                  t        |      t        |       |j                  j                         |t        |j                  d         t        |j                  d                     y )Nz{0} out of {1} geometries are not {3}equal.
Indices where geometries are not {3}equal: {2} 
The first not {3}equal geometry:
Left: {4}
Right: {5}
zalmost  r   )
r   r   r   AssertionErrorr(   r&   r%   to_listr?   iloc)r0   r1   r5   assert_error_messagepreciseequalunequal_left_geomsunequal_right_geomss           r   r/   r/      s    	  (u5!$.99;!5&\#UFm ''&'D	"((002!"4"9"9!"<=!"5":":1"=>	
 		
 r   c           
      F   	 ddl m}m} |rt        | t              sJ t        | t        |            sJ |	r| j                  |j                  n| j                  | j                  vr|j                  |j                  vrnj| j                  s|j                  snQ| j                  |j                  k(  s8J t        | t              st        |       } t        |t              st        |      }| j                  |j                  k(  s;J d| j                  d|j                  d| j                  d|j                         |r| j                  |      }  || j                  |j                  |d	       | j                  j                         D ].  \  }}t        |t              st!        | |   ||   |
||||	
       0 | j                  |j                  k(  sJ | j#                  d      }|j#                  d      } ||||||d       y# t        $ r ddlm}m} Y w xY w)a{  Check that two GeoDataFrames are equal.

    Parameters
    ----------
    left, right : two GeoDataFrames
    check_dtype : bool, default True
        Whether to check the DataFrame dtype is identical.
    check_index_type, check_column_type : bool, default 'equiv'
        Check that index types are equal.
    check_frame_type : bool, default True
        Check that both are same type (*and* are GeoDataFrames). If False,
        will attempt to convert both into GeoDataFrame.
    check_like : bool, default False
        If true, ignore the order of rows & columns
    check_less_precise : bool, default False
        If True, use geom_equals_exact. if False, use geom_equals.
    check_geom_type : bool, default False
        If True, check that all the geom types are equal.
    check_crs: bool, default True
        If `check_frame_type` is True, then also check that the
        crs matches.
    normalize: bool, default False
        If True, normalize the geometries before comparing equality.
        Typically useful with ``check_less_precise=True``, which uses
        ``geom_equals_exact`` and requires exact coordinate order.
    r   )assert_frame_equalassert_index_equalNz#GeoDataFrame shape mismatch, left: z	, right: z.
Left columns: z, right columns: zGeoDataFrame.columns)exactobj)r.   r2   r5   r6   r7   r"   )excluder   )r2   r3   check_column_typerN   )pandas.testingrK   rL   ImportErrorpandas.util.testingr!   r   r)   _geometry_column_namecolumnsr*   shapereindex_likedtypesitemsr   r9   select_dtypes)r0   r1   r2   r3   rP   check_frame_type
check_liker5   r6   r7   r.   rK   rL   colr'   left2right2s                    r   assert_geodataframe_equalr`      s   NOI
 $---$U,,, **2//7**$,,>//u}}DXXeiixx599,,,$-%D%. 'E ::$ 
-djj^9U[[O T((9%--9J	L$
   ' emm+<BX
 kk'') 

Ue]+"S	c
#'#5 /#
 %%)D)DDDD z2E   4F)+A  ONNOs   H H H )TFTFFTF)	Tequivra   TFFFTF)__doc__r
   pandasr   	geopandasr   r   geopandas.arrayr   r   r   r   r   r#   r9   r?   r/   r`    r   r   <module>rg      sy    2   - )#$,/$068 L9^
B qr   