def test_set_operation_reduce_1dim(n, func, related_func): actual = func(reduce_test_data[:n]) # perform the reduction in a python loop and compare expected = reduce_test_data[0] for i in range(1, n): expected = related_func(expected, reduce_test_data[i]) assert shapely.equals(actual, expected)
def test_set_operation_prec_array(a, func, grid_size): actual = func([a, a], point, grid_size=grid_size) assert actual.shape == (2, ) assert isinstance(actual[0], Geometry) # results should match the operation when the precision is previously set # to same grid_size b = shapely.set_precision(a, grid_size=grid_size) point2 = shapely.set_precision(point, grid_size=grid_size) expected = func([b, b], point2) assert shapely.equals(shapely.normalize(actual), shapely.normalize(expected)).all()
def equals(self, other): """Returns True if geometries are equal, else False. This method considers point-set equality (or topological equality), and is equivalent to (self.within(other) & self.contains(other)). Examples -------- >>> LineString( ... [(0, 0), (2, 2)] ... ).equals( ... LineString([(0, 0), (1, 1), (2, 2)]) ... ) True Returns ------- bool """ return bool(shapely.equals(self, other))
def test_minimum_rotated_rectangle(geometry, expected): actual = shapely.minimum_rotated_rectangle(geometry) assert shapely.equals(actual, expected).all()
def test_oriented_envelope(geometry, expected): actual = shapely.oriented_envelope(geometry) assert shapely.equals(actual, expected).all()
def test_shortest_line(prepare): g1 = shapely.linestrings([(0, 0), (1, 0), (1, 1)]) g2 = shapely.linestrings([(0, 3), (3, 0)]) actual = shapely.shortest_line(_prepare_input(g1, prepare), g2) expected = shapely.linestrings([(1, 1), (1.5, 1.5)]) assert shapely.equals(actual, expected)
def test_union_all_prec(geom, grid_size, expected): actual = shapely.union_all(geom, grid_size=grid_size) assert shapely.equals(actual, expected)