def test_complicated(self): edge_tuples = [('0', 1, 2, 'a') + tuple(self.attributes), ('0', 2, 3, 'a') + tuple(self.attributes), ('0', 3, 4, 'a') + tuple(self.attributes), ('0', 4, 5, 'p') + tuple(self.attributes), ('0', 5, 6, 'r') + tuple(self.attributes), ('0', 6, 7, 'r') + tuple(self.attributes), ('0', 7, 5, 'r') + tuple(self.attributes), ('0', 4, 8, 'f') + tuple(self.attributes), ('0', 8, 9, 'f') + tuple(self.attributes), ('0', 9, 1, 'f') + tuple(self.attributes)] df = make_a_dataframe(edge_tuples) df = simplify_undirected_as_dataframe(df) e1, e2, e3, e4 = df.path.to_list() h1, h2, h3, h4 = df.highway.to_list() np.testing.assert_equal(np.array([1, 2, 3, 4]), e1) np.testing.assert_equal(np.array([4, 5]), e2) np.testing.assert_equal(np.array([4, 8, 9, 1]), e3) np.testing.assert_equal(np.array([5, 6, 7, 5]), e4) self.assertEquals('a', h1) self.assertEquals('p', h2) self.assertEquals('f', h3) self.assertEquals('r', h4)
def test_loop(self): edge_tuples = [('0', 1, 2, 'a') + tuple(self.attributes), ('0', 2, 3, 'a') + tuple(self.attributes), ('0', 3, 4, 'a') + tuple(self.attributes), ('0', 4, 1, 'a') + tuple(self.attributes)] df = make_a_dataframe(edge_tuples) df = simplify_undirected_as_dataframe(df) e1, = df.path.to_list() np.testing.assert_equal(np.array([4, 1, 2, 3]), e1)
def test_no_loop_change_highway(self): edge_tuples = [('0', 1, 2, 'a') + tuple(self.attributes), ('0', 2, 3, 'b') + tuple(self.attributes), ('0', 3, 4, 'a') + tuple(self.attributes)] df = make_a_dataframe(edge_tuples) df = simplify_undirected_as_dataframe(df) e1, e2, e3 = df.path.to_list() np.testing.assert_equal(np.array([1, 2]), e1) np.testing.assert_equal(np.array([2, 3]), e2) np.testing.assert_equal(np.array([3, 4]), e3)
def test_no_loop_line(self): edge_tuples = [('0', 1, 2, 'a') + tuple([ True, 3, 2, 2.0, True, 0, True, 0, 30, True, LineString([(0, 0), (1, 0)]) ]), ('0', 2, 3, 'a') + tuple([ True, 3, 2, 2.0, True, 0, True, 0, 30, True, LineString([(1, 0), (2, 0)]) ]), ('0', 3, 4, 'a') + tuple([ True, 3, 2, 2.0, True, 0, True, 0, 30, True, LineString([(2, 0), (3, 0)]) ])] df = make_a_dataframe(edge_tuples) df = simplify_undirected_as_dataframe(df) e1, = df.path.to_list() np.testing.assert_equal(np.array([1, 2, 3, 4]), e1) l1, = df.geometry.to_list() print(df.geometry) self.assertEquals(l1, LineString([(0, 0), (1, 0), (2, 0), (3, 0)]))