<s> from __future__ import absolute_import <EOL> import string <EOL> import numpy as np <EOL> from numpy . testing import assert_array_equal <EOL> from pandas . util . testing import assert_series_equal , assert_frame_equal <EOL> from pandas import Series , DataFrame , MultiIndex <EOL> from shapely . geometry import ( <EOL> Point , LinearRing , LineString , Polygon , MultiPoint <EOL> ) <EOL> from shapely . geometry . collection import GeometryCollection <EOL> from shapely . ops import unary_union <EOL> from geopandas import GeoSeries , GeoDataFrame <EOL> from geopandas . base import GeoPandasBase <EOL> from geopandas . tests . util import ( <EOL> unittest , geom_equals , geom_almost_equals , assert_geoseries_equal <EOL> ) <EOL> class TestGeomMethods ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . t1 = Polygon ( [ ( <NUM_LIT:0> , <NUM_LIT:0> ) , ( <NUM_LIT:1> , <NUM_LIT:0> ) , ( <NUM_LIT:1> , <NUM_LIT:1> ) ] ) <EOL> self . t2 = Polygon ( [ ( <NUM_LIT:0> , <NUM_LIT:0> ) , ( <NUM_LIT:1> , <NUM_LIT:1> ) , ( <NUM_LIT:0> , <NUM_LIT:1> ) ] ) <EOL> self . t3 = Polygon ( [ ( <NUM_LIT:2> , <NUM_LIT:0> ) , ( <NUM_LIT:3> , <NUM_LIT:0> ) , ( <NUM_LIT:3> , <NUM_LIT:1> ) ] ) <EOL> self . sq = Polygon ( [ ( <NUM_LIT:0> , <NUM_LIT:0> ) , ( <NUM_LIT:1> , <NUM_LIT:0> ) , ( <NUM_LIT:1> , <NUM_LIT:1> ) , ( <NUM_LIT:0> , <NUM_LIT:1> ) ] ) <EOL> self . inner_sq = Polygon ( [ ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , <EOL> ( <NUM_LIT> , <NUM_LIT> ) ] ) <EOL> self . nested_squares = Polygon ( self . sq . boundary , <EOL> [ self . inner_sq . boundary ] ) <EOL> self . p0 = Point ( <NUM_LIT:5> , <NUM_LIT:5> ) <EOL> self . g0 = GeoSeries ( [ self . t1 , self . t2 , self . sq , self . inner_sq , <EOL> self . nested_squares , self . p0 ] ) <EOL> self . g1 = GeoSeries ( [ self . t1 , self . sq ] ) <EOL> self . g2 = GeoSeries ( [ self . sq , self . t1 ] ) <EOL> self . g3 = GeoSeries ( [ self . t1 , self . t2 ] ) <EOL> self . g3 . crs = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : True } <EOL> self . g4 = GeoSeries ( [ self . t2 , self . t1 ] ) <EOL> self . na = GeoSeries ( [ self . t1 , self . t2 , Polygon ( ) ] ) <EOL> self . na_none = GeoSeries ( [ self . t1 , None ] ) <EOL> self . a1 = self . g1 . copy ( ) <EOL> self . a1 . index = [ '<STR_LIT:A>' , '<STR_LIT:B>' ] <EOL> self . a2 = self . g2 . copy ( ) <EOL> self . a2 . index = [ '<STR_LIT:B>' , '<STR_LIT:C>' ] <EOL> self . esb = Point ( - <NUM_LIT> , <NUM_LIT> ) <EOL> self . sol = Point ( - <NUM_LIT> , <NUM_LIT> ) <EOL> self . landmarks = GeoSeries ( [ self . esb , self . sol ] , <EOL> crs = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : True } ) <EOL> self . l1 = LineString ( [ ( <NUM_LIT:0> , <NUM_LIT:0> ) , ( <NUM_LIT:0> , <NUM_LIT:1> ) , ( <NUM_LIT:1> , <NUM_LIT:1> ) ] ) <EOL> self . l2 = LineString ( [ ( <NUM_LIT:0> , <NUM_LIT:0> ) , ( <NUM_LIT:1> , <NUM_LIT:0> ) , ( <NUM_LIT:1> , <NUM_LIT:1> ) , ( <NUM_LIT:0> , <NUM_LIT:1> ) ] ) <EOL> self . g5 = GeoSeries ( [ self . l1 , self . l2 ] ) <EOL> self . g6 = GeoSeries ( [ self . p0 , self . t3 ] ) <EOL> self . l3 = LineString ( [ ( <NUM_LIT:0> , <NUM_LIT:0> ) , ( <NUM_LIT:1> , <NUM_LIT:1> ) ] ) <EOL> self . l4 = LineString ( [ ( <NUM_LIT:0> , <NUM_LIT:1> ) , ( <NUM_LIT:1> , <NUM_LIT:0> ) ] ) <EOL> self . crossed_lines = GeoSeries ( [ self . l3 , self . l4 ] ) <EOL> self . gdf1 = GeoDataFrame ( { '<STR_LIT>' : self . g1 , <EOL> '<STR_LIT>' : [ <NUM_LIT:1.0> , <NUM_LIT> ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] } ) <EOL> self . gdf2 = GeoDataFrame ( { '<STR_LIT>' : self . g1 , <EOL> '<STR_LIT>' : [ <NUM_LIT:4> , <NUM_LIT:5> ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT:string>' ] } ) <EOL> def _test_unary_real ( self , op , expected , a ) : <EOL> """<STR_LIT>""" <EOL> fcmp = assert_series_equal <EOL> self . _test_unary ( op , expected , a , fcmp ) <EOL> def _test_unary_topological ( self , op , expected , a ) : <EOL> if isinstance ( expected , GeoPandasBase ) : <EOL> fcmp = assert_geoseries_equal <EOL> else : <EOL> fcmp = lambda a , b : self . assert_ ( a . equals ( b ) ) <EOL> self . _test_unary ( op , expected , a , fcmp ) <EOL> def _test_binary_topological ( self , op , expected , a , b , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( expected , GeoPandasBase ) : <EOL> fcmp = assert_geoseries_equal <EOL> else : <EOL> fcmp = lambda a , b : self . assert_ ( geom_equals ( a , b ) ) <EOL> if isinstance ( b , GeoPandasBase ) : <EOL> right_df = True <EOL> else : <EOL> right_df = False <EOL> self . _binary_op_test ( op , expected , a , b , fcmp , True , right_df , <EOL> * args , ** kwargs ) <EOL> def _test_binary_real ( self , op , expected , a , b , * args , ** kwargs ) : <EOL> fcmp = assert_series_equal <EOL> self . _binary_op_test ( op , expected , a , b , fcmp , True , False , * args , ** kwargs ) <EOL> def _test_binary_operator ( self , op , expected , a , b ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( expected , GeoPandasBase ) : <EOL> fcmp = assert_geoseries_equal <EOL> else : <EOL> fcmp = lambda a , b : self . assert_ ( geom_equals ( a , b ) ) <EOL> if isinstance ( b , GeoPandasBase ) : <EOL> right_df = True <EOL> else : <EOL> right_df = False <EOL> self . _binary_op_test ( op , expected , a , b , fcmp , False , right_df ) <EOL> def _binary_op_test ( self , op , expected , left , right , fcmp , left_df , <EOL> right_df , <EOL> * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> def _make_gdf ( s ) : <EOL> n = len ( s ) <EOL> col1 = string . ascii_lowercase [ : n ] <EOL> col2 = range ( n ) <EOL> return GeoDataFrame ( { '<STR_LIT>' : s . values , <EOL> '<STR_LIT>' : col1 , <EOL> '<STR_LIT>' : col2 } , <EOL> index = s . index , crs = s . crs ) <EOL> result = getattr ( left , op ) ( right , * args , ** kwargs ) <EOL> fcmp ( result , expected ) <EOL> if left_df : <EOL> gdf_left = _make_gdf ( left ) <EOL> result = getattr ( gdf_left , op ) ( right , * args , ** kwargs ) <EOL> fcmp ( result , expected ) <EOL> if right_df : <EOL> gdf_right = _make_gdf ( right ) <EOL> result = getattr ( left , op ) ( gdf_right , * args , ** kwargs ) <EOL> fcmp ( result , expected ) <EOL> if left_df : <EOL> result = getattr ( gdf_left , op ) ( gdf_right , * args , ** kwargs ) <EOL> fcmp ( result , expected ) <EOL> def _test_unary ( self , op , expected , a , fcmp ) : <EOL> result = getattr ( a , op ) <EOL> fcmp ( result , expected ) <EOL> gdf = self . gdf1 . set_geometry ( a ) <EOL> result = getattr ( gdf , op ) <EOL> fcmp ( result , expected ) <EOL> def test_intersection ( self ) : <EOL> self . _test_binary_topological ( '<STR_LIT>' , self . t1 , <EOL> self . g1 , self . g2 ) <EOL> def test_union_series ( self ) : <EOL> self . _test_binary_topological ( '<STR_LIT>' , self . sq , self . g1 , self . g2 ) <EOL> def test_union_polygon ( self ) : <EOL> self . _test_binary_topological ( '<STR_LIT>' , self . sq , self . g1 , self . t2 ) <EOL> def test_symmetric_difference_series ( self ) : <EOL> self . _test_binary_topological ( '<STR_LIT>' , self . sq , <EOL> self . g3 , self . g4 ) <EOL> def test_symmetric_difference_poly ( self ) : <EOL> expected = GeoSeries ( [ GeometryCollection ( ) , self . sq ] , crs = self . g3 . crs ) <EOL> self . _test_binary_topological ( '<STR_LIT>' , expected , <EOL> self . g3 , self . t1 ) <EOL> def test_difference_series ( self ) : <EOL> expected = GeoSeries ( [ GeometryCollection ( ) , self . t2 ] ) <EOL> self . _test_binary_topological ( '<STR_LIT>' , expected , <EOL> self . g1 , self . g2 ) <EOL> def test_difference_poly ( self ) : <EOL> expected = GeoSeries ( [ self . t1 , self . t1 ] ) <EOL> self . _test_binary_topological ( '<STR_LIT>' , expected , <EOL> self . g1 , self . t2 ) <EOL> def test_boundary ( self ) : <EOL> l1 = LineString ( [ ( <NUM_LIT:0> , <NUM_LIT:0> ) , ( <NUM_LIT:1> , <NUM_LIT:0> ) , ( <NUM_LIT:1> , <NUM_LIT:1> ) , ( <NUM_LIT:0> , <NUM_LIT:0> ) ] ) <EOL> l2 = LineString ( [ ( <NUM_LIT:0> , <NUM_LIT:0> ) , ( <NUM_LIT:1> , <NUM_LIT:0> ) , ( <NUM_LIT:1> , <NUM_LIT:1> ) , ( <NUM_LIT:0> , <NUM_LIT:1> ) , ( <NUM_LIT:0> , <NUM_LIT:0> ) ] ) <EOL> expected = GeoSeries ( [ l1 , l2 ] , index = self . g1 . index , crs = self . g1 . crs ) <EOL> self . _test_unary_topological ( '<STR_LIT>' , expected , self . g1 ) <EOL> def test_area ( self ) : <EOL> expected = Series ( np . array ( [ <NUM_LIT:0.5> , <NUM_LIT:1.0> ] ) , index = self . g1 . index ) <EOL> self . _test_unary_real ( '<STR_LIT>' , expected , self . g1 ) <EOL> expected = Series ( np . array ( [ <NUM_LIT:0.5> , np . nan ] ) , index = self . na_none . index ) <EOL> self . _test_unary_real ( '<STR_LIT>' , expected , self . na_none ) <EOL> def test_bounds ( self ) : <EOL> expected = DataFrame ( { '<STR_LIT>' : [ <NUM_LIT:0.0> , <NUM_LIT:0.0> ] , '<STR_LIT>' : [ <NUM_LIT:0.0> , <NUM_LIT:0.0> ] , <EOL> '<STR_LIT>' : [ <NUM_LIT:1.0> , <NUM_LIT:1.0> ] , '<STR_LIT>' : [ <NUM_LIT:1.0> , <NUM_LIT:1.0> ] } , <EOL> index = self . g1 . index , <EOL> columns = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> result = self . g1 . bounds <EOL> assert_frame_equal ( expected , result ) <EOL> gdf = self . gdf1 . set_geometry ( self . g1 ) <EOL> result = gdf . bounds <EOL> assert_frame_equal ( expected , result ) <EOL> def test_unary_union ( self ) : <EOL> p1 = self . t1 <EOL> p2 = Polygon ( [ ( <NUM_LIT:2> , <NUM_LIT:0> ) , ( <NUM_LIT:3> , <NUM_LIT:0> ) , ( <NUM_LIT:3> , <NUM_LIT:1> ) ] ) <EOL> expected = unary_union ( [ p1 , p2 ] ) <EOL> g = GeoSeries ( [ p1 , p2 ] ) <EOL> self . _test_unary_topological ( '<STR_LIT>' , expected , g ) <EOL> def test_contains ( self ) : <EOL> expected = [ True , False , True , False , False , False ] <EOL> assert_array_equal ( expected , self . g0 . contains ( self . t1 ) ) <EOL> def test_length ( self ) : <EOL> expected = Series ( np . array ( [ <NUM_LIT:2> + np . sqrt ( <NUM_LIT:2> ) , <NUM_LIT:4> ] ) , index = self . g1 . index ) <EOL> self . _test_unary_real ( '<STR_LIT>' , expected , self . g1 ) <EOL> expected = Series ( <EOL> np . array ( [ <NUM_LIT:2> + np . sqrt ( <NUM_LIT:2> ) , np . nan ] ) , <EOL> index = self . na_none . index ) <EOL> self . _test_unary_real ( '<STR_LIT>' , expected , self . na_none ) <EOL> def test_crosses ( self ) : <EOL> expected = [ False , False , False , False , False , False ] <EOL> assert_array_equal ( expected , self . g0 . crosses ( self . t1 ) ) <EOL> expected = [ False , True ] <EOL> assert_array_equal ( expected , self . crossed_lines . crosses ( self . l3 ) ) <EOL> def test_disjoint ( self ) : <EOL> expected = [ False , False , False , False , False , True ] <EOL> assert_array_equal ( expected , self . g0 . disjoint ( self . t1 ) ) <EOL> def test_distance ( self ) : <EOL> expected = Series ( np . array ( [ <EOL> np . sqrt ( ( <NUM_LIT:5> - <NUM_LIT:1> ) ** <NUM_LIT:2> + ( <NUM_LIT:5> - <NUM_LIT:1> ) ** <NUM_LIT:2> ) , <EOL> np . nan ] ) , <EOL> self . na_none . index ) <EOL> assert_array_equal ( expected , self . na_none . distance ( self . p0 ) ) <EOL> expected = Series ( np . array ( [ np . sqrt ( <NUM_LIT:4> ** <NUM_LIT:2> + <NUM_LIT:4> ** <NUM_LIT:2> ) , np . nan ] ) , <EOL> self . g6 . index ) <EOL> assert_array_equal ( expected , self . g6 . distance ( self . na_none ) ) <EOL> def test_intersects ( self ) : <EOL> expected = [ True , True , True , True , True , False ] <EOL> assert_array_equal ( expected , self . g0 . intersects ( self . t1 ) ) <EOL> expected = [ True , False ] <EOL> assert_array_equal ( expected , self . na_none . intersects ( self . t2 ) ) <EOL> def test_overlaps ( self ) : <EOL> expected = [ True , True , False , False , False , False ] <EOL> assert_array_equal ( expected , self . g0 . overlaps ( self . inner_sq ) ) <EOL> expected = [ False , False ] <EOL> assert_array_equal ( expected , self . g4 . overlaps ( self . t1 ) ) <EOL> def test_touches ( self ) : <EOL> expected = [ False , True , False , False , False , False ] <EOL> assert_array_equal ( expected , self . g0 . touches ( self . t1 ) ) <EOL> def test_within ( self ) : <EOL> expected = [ True , False , False , False , False , False ] <EOL> assert_array_equal ( expected , self . g0 . within ( self . t1 ) ) <EOL> expected = [ True , True , True , True , True , False ] <EOL> assert_array_equal ( expected , self . g0 . within ( self . sq ) ) <EOL> def test_is_valid ( self ) : <EOL> expected = Series ( np . array ( [ True ] * len ( self . g1 ) ) , self . g1 . index ) <EOL> self . _test_unary_real ( '<STR_LIT>' , expected , self . g1 ) <EOL> def test_is_empty ( self ) : <EOL> expected = Series ( np . array ( [ False ] * len ( self . g1 ) ) , self . g1 . index ) <EOL> self . _test_unary_real ( '<STR_LIT>' , expected , self . g1 ) <EOL> def test_is_ring ( self ) : <EOL> expected = Series ( np . array ( [ True ] * len ( self . g1 ) ) , self . g1 . index ) <EOL> self . _test_unary_real ( '<STR_LIT>' , expected , self . g1 ) <EOL> def test_is_simple ( self ) : <EOL> expected = Series ( np . array ( [ True ] * len ( self . g1 ) ) , self . g1 . index ) <EOL> self . _test_unary_real ( '<STR_LIT>' , expected , self . g1 ) <EOL> def test_exterior ( self ) : <EOL> exp_exterior = GeoSeries ( [ LinearRing ( p . boundary ) for p in self . g3 ] ) <EOL> for expected , computed in zip ( exp_exterior , self . g3 . exterior ) : <EOL> assert computed . equals ( expected ) <EOL> def test_interiors ( self ) : <EOL> square_series = GeoSeries ( self . nested_squares ) <EOL> exp_interiors = GeoSeries ( [ LinearRing ( self . inner_sq . boundary ) ] ) <EOL> for expected , computed in zip ( exp_interiors , square_series . interiors ) : <EOL> assert computed [ <NUM_LIT:0> ] . equals ( expected ) <EOL> def test_interpolate ( self ) : <EOL> expected = GeoSeries ( [ Point ( <NUM_LIT:0.5> , <NUM_LIT:1.0> ) , Point ( <NUM_LIT> , <NUM_LIT:1.0> ) ] ) <EOL> self . _test_binary_topological ( '<STR_LIT>' , expected , self . g5 , <EOL> <NUM_LIT> , normalized = True ) <EOL> expected = GeoSeries ( [ Point ( <NUM_LIT:0.5> , <NUM_LIT:1.0> ) , Point ( <NUM_LIT:1.0> , <NUM_LIT:0.5> ) ] ) <EOL> self . _test_binary_topological ( '<STR_LIT>' , expected , self . g5 , <EOL> <NUM_LIT> ) <EOL> def test_project ( self ) : <EOL> expected = Series ( [ <NUM_LIT> , <NUM_LIT> ] , index = self . g5 . index ) <EOL> p = Point ( <NUM_LIT:1.0> , <NUM_LIT:0.5> ) <EOL> self . _test_binary_real ( '<STR_LIT>' , expected , self . g5 , p ) <EOL> expected = Series ( [ <NUM_LIT:1.0> , <NUM_LIT:0.5> ] , index = self . g5 . index ) <EOL> self . _test_binary_real ( '<STR_LIT>' , expected , self . g5 , p , <EOL> normalized = True ) <EOL> def test_translate_tuple ( self ) : <EOL> trans = self . sol . x - self . esb . x , self . sol . y - self . esb . y <EOL> self . assert_ ( self . landmarks . translate ( * trans ) [ <NUM_LIT:0> ] . equals ( self . sol ) ) <EOL> res = self . gdf1 . set_geometry ( self . landmarks ) . translate ( * trans ) [ <NUM_LIT:0> ] <EOL> self . assert_ ( res . equals ( self . sol ) ) <EOL> def test_rotate ( self ) : <EOL> angle = <NUM_LIT> <EOL> expected = self . g4 <EOL> o = Point ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> res = self . g4 . rotate ( angle , origin = o ) . rotate ( - angle , origin = o ) <EOL> self . assert_ ( geom_almost_equals ( self . g4 , res ) ) <EOL> res = self . gdf1 . set_geometry ( self . g4 ) . rotate ( angle , origin = Point ( <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> self . assert_ ( geom_almost_equals ( expected , <EOL> res . rotate ( - angle , origin = o ) ) ) <EOL> def test_scale ( self ) : <EOL> expected = self . g4 <EOL> scale = <NUM_LIT> , <NUM_LIT:1.> <EOL> inv = tuple ( <NUM_LIT:1.> / i for i in scale ) <EOL> o = Point ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> res = self . g4 . scale ( * scale , origin = o ) . scale ( * inv , origin = o ) <EOL> self . assertTrue ( geom_almost_equals ( expected , res ) ) <EOL> res = self . gdf1 . set_geometry ( self . g4 ) . scale ( * scale , origin = o ) <EOL> res = res . scale ( * inv , origin = o ) <EOL> self . assert_ ( geom_almost_equals ( expected , res ) ) <EOL> def test_skew ( self ) : <EOL> expected = self . g4 <EOL> skew = <NUM_LIT> <EOL> o = Point ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> res = self . g4 . skew ( xs = skew , origin = o ) . skew ( xs = - skew , origin = o ) <EOL> self . assert_ ( geom_almost_equals ( expected , res ) ) <EOL> res = self . gdf1 . set_geometry ( self . g4 ) . skew ( xs = skew , origin = o ) <EOL> res = res . skew ( xs = - skew , origin = o ) <EOL> self . assert_ ( geom_almost_equals ( expected , res ) ) <EOL> res = self . g4 . skew ( ys = skew , origin = o ) . skew ( ys = - skew , origin = o ) <EOL> self . assert_ ( geom_almost_equals ( expected , res ) ) <EOL> res = self . gdf1 . set_geometry ( self . g4 ) . skew ( ys = skew , origin = o ) <EOL> res = res . skew ( ys = - skew , origin = o ) <EOL> self . assert_ ( geom_almost_equals ( expected , res ) ) <EOL> def test_envelope ( self ) : <EOL> e = self . g3 . envelope <EOL> self . assertTrue ( np . alltrue ( e . geom_equals ( self . sq ) ) ) <EOL> self . assertIsInstance ( e , GeoSeries ) <EOL> self . assertEqual ( self . g3 . crs , e . crs ) <EOL> def test_total_bounds ( self ) : <EOL> bbox = self . sol . x , self . sol . y , self . esb . x , self . esb . y <EOL> self . assert_ ( self . landmarks . total_bounds , bbox ) <EOL> df = GeoDataFrame ( { '<STR_LIT>' : self . landmarks , <EOL> '<STR_LIT>' : range ( len ( self . landmarks ) ) } ) <EOL> self . assert_ ( df . total_bounds , bbox ) <EOL> def test_explode ( self ) : <EOL> s = GeoSeries ( [ MultiPoint ( [ ( <NUM_LIT:0> , <NUM_LIT:0> ) , ( <NUM_LIT:1> , <NUM_LIT:1> ) ] ) , <EOL> MultiPoint ( [ ( <NUM_LIT:2> , <NUM_LIT:2> ) , ( <NUM_LIT:3> , <NUM_LIT:3> ) , ( <NUM_LIT:4> , <NUM_LIT:4> ) ] ) ] ) <EOL> index = [ ( <NUM_LIT:0> , <NUM_LIT:0> ) , ( <NUM_LIT:0> , <NUM_LIT:1> ) , ( <NUM_LIT:1> , <NUM_LIT:0> ) , ( <NUM_LIT:1> , <NUM_LIT:1> ) , ( <NUM_LIT:1> , <NUM_LIT:2> ) ] <EOL> expected = GeoSeries ( [ Point ( <NUM_LIT:0> , <NUM_LIT:0> ) , Point ( <NUM_LIT:1> , <NUM_LIT:1> ) , Point ( <NUM_LIT:2> , <NUM_LIT:2> ) , Point ( <NUM_LIT:3> , <NUM_LIT:3> ) , <EOL> Point ( <NUM_LIT:4> , <NUM_LIT:4> ) ] , index = MultiIndex . from_tuples ( index ) ) <EOL> assert_geoseries_equal ( expected , s . explode ( ) ) <EOL> df = self . gdf1 [ : <NUM_LIT:2> ] . set_geometry ( s ) <EOL> assert_geoseries_equal ( expected , df . explode ( ) ) <EOL> def test_intersection_operator ( self ) : <EOL> self . _test_binary_operator ( '<STR_LIT>' , self . t1 , self . g1 , self . g2 ) <EOL> def test_union_operator ( self ) : <EOL> self . _test_binary_operator ( '<STR_LIT>' , self . sq , self . g1 , self . g2 ) <EOL> def test_union_operator_polygon ( self ) : <EOL> self . _test_binary_operator ( '<STR_LIT>' , self . sq , self . g1 , self . t2 ) <EOL> def test_symmetric_difference_operator ( self ) : <EOL> self . _test_binary_operator ( '<STR_LIT>' , self . sq , self . g3 , self . g4 ) <EOL> def test_difference_series ( self ) : <EOL> expected = GeoSeries ( [ GeometryCollection ( ) , self . t2 ] ) <EOL> self . _test_binary_operator ( '<STR_LIT>' , expected , self . g1 , self . g2 ) <EOL> def test_difference_poly ( self ) : <EOL> expected = GeoSeries ( [ self . t1 , self . t1 ] ) <EOL> self . _test_binary_operator ( '<STR_LIT>' , expected , self . g1 , self . t2 ) </s>
