<s> from . import unittest <EOL> import pytest <EOL> from shapely . geometry import Point , LineString , Polygon , MultiPoint , GeometryCollection <EOL> from shapely . wkt import loads <EOL> from shapely . geos import TopologicalError , geos_version <EOL> class OperationsTestCase ( unittest . TestCase ) : <EOL> def test_operations ( self ) : <EOL> point = Point ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) <EOL> self . assertEqual ( point . area , <NUM_LIT:0.0> ) <EOL> self . assertEqual ( point . length , <NUM_LIT:0.0> ) <EOL> self . assertAlmostEqual ( point . distance ( Point ( - <NUM_LIT:1.0> , - <NUM_LIT:1.0> ) ) , <EOL> <NUM_LIT> ) <EOL> self . assertIsInstance ( point . envelope , Point ) <EOL> self . assertIsInstance ( point . intersection ( Point ( - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , <EOL> GeometryCollection ) <EOL> self . assertIsInstance ( point . buffer ( <NUM_LIT> ) , Polygon ) <EOL> self . assertIsInstance ( point . buffer ( <NUM_LIT> , <NUM_LIT:32> ) , Polygon ) <EOL> p = loads ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> expected = loads ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> s = p . simplify ( <NUM_LIT> , preserve_topology = False ) <EOL> self . assertTrue ( s . equals_exact ( expected , <NUM_LIT> ) ) <EOL> p = loads ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> expected = loads ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> s = p . simplify ( <NUM_LIT> , preserve_topology = True ) <EOL> self . assertTrue ( s . equals_exact ( expected , <NUM_LIT> ) ) <EOL> self . assertIsInstance ( point . convex_hull , Point ) <EOL> self . assertIsInstance ( point . difference ( Point ( - <NUM_LIT:1> , <NUM_LIT:1> ) ) , Point ) <EOL> self . assertIsInstance ( point . symmetric_difference ( Point ( - <NUM_LIT:1> , <NUM_LIT:1> ) ) , <EOL> MultiPoint ) <EOL> self . assertIsInstance ( point . boundary , GeometryCollection ) <EOL> self . assertIsInstance ( point . union ( Point ( - <NUM_LIT:1> , <NUM_LIT:1> ) ) , MultiPoint ) <EOL> self . assertIsInstance ( point . representative_point ( ) , Point ) <EOL> self . assertIsInstance ( point . centroid , Point ) <EOL> def test_relate ( self ) : <EOL> self . assertEqual ( Point ( <NUM_LIT:0> , <NUM_LIT:0> ) . relate ( Point ( - <NUM_LIT:1> , - <NUM_LIT:1> ) ) , '<STR_LIT>' ) <EOL> invalid_polygon = loads ( '<STR_LIT>' ) <EOL> assert ( not invalid_polygon . is_valid ) <EOL> with pytest . raises ( TopologicalError ) : <EOL> invalid_polygon . relate ( invalid_polygon ) <EOL> @ unittest . skipIf ( geos_version < ( <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:0> ) , '<STR_LIT>' ) <EOL> def test_hausdorff_distance ( self ) : <EOL> point = Point ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> line = LineString ( [ ( <NUM_LIT:2> , <NUM_LIT:0> ) , ( <NUM_LIT:2> , <NUM_LIT:4> ) , ( <NUM_LIT:3> , <NUM_LIT:4> ) ] ) <EOL> distance = point . hausdorff_distance ( line ) <EOL> self . assertEqual ( distance , point . distance ( Point ( <NUM_LIT:3> , <NUM_LIT:4> ) ) ) <EOL> def test_suite ( ) : <EOL> return unittest . TestLoader ( ) . loadTestsFromTestCase ( OperationsTestCase ) </s>
