def test010(self): """ A---B---C---D---E---F levels: 7 6 5 4 6 8 result: 0 1 2 3 1 0 """ G = nx.Graph() nodes = {"A": Put(coords=(0, 0, 7)), "B": Put(coords=(0, 1, 6)), "C": Put(coords=(0, 2, 5)), "D": Put(coords=(0, 3, 4)), "E": Put(coords=(0, 4, 6)), "F": Put(coords=(0, 5, 8)), } for label, obj in nodes.items(): G.add_node(label, obj=obj) labels = sorted(nodes) for p, c in zip(labels, labels[1:]): G.add_edge(p, c) compute_lost_water_depth(G, "A") self.assertEqual(0, G.node["A"]['obj'].flooded) self.assertEqual(1, G.node["B"]['obj'].flooded) self.assertEqual(2, G.node["C"]['obj'].flooded) self.assertEqual(3, G.node["D"]['obj'].flooded) self.assertEqual(1, G.node["E"]['obj'].flooded) self.assertEqual(0, G.node["F"]['obj'].flooded)
def test000(self): "watering a simple network" # XXX DISABLED by Remco # # First, the compute_lost_water_depth function has changed slightly # (the z values of puts is now different). This needs to be reflected # in this function. # # But, the reported flooding depth has also changed, and currently # I trust the function better than this test. It should probably be # replaced by a set of smaller tests that can more easily be inspected # by hand. return pool = {} G = nx.Graph() parse("lizard_riool/data/f3478-bb.rmb", pool) convert_to_graph(pool, G) compute_lost_water_depth(G, (0.0, 0.0)) target = [((0.0, 0.0), 0.0, 0), ((0.0, 1.0), 2.0, 0), ((0.0, 2.0), 0.0, 2.0), ((0.0, 3.0), 1.0, 1.0), ((0.0, 4.0), 2.0, 0), ((0.0, 5.0), 3.0, 0), ((0.0, 6.0), 4.0, 0), ((0.0, 7.0), 3.0, 1.0), ((0.0, 8.0), 4.0, 0), ((0.8, 5.6), 4.0, 0), ((1.6, 6.2), 3.0, 1.0), ((2.4000000000000004, 6.8), 3.0, 1.0), ((3.2, 7.4), 3.0, 1.0), ((4.0, 8.0), 4.0, 0), ((1.0, 0.0), 2.0, 0), ((2.0, 0.0), 1.0, 1.0), ((3.0, 0.0), 2.0, 0), ((3.5, 0.0), 3.0, 0), ((5.0, 0.0), 3.0, 0), ((1.0, 5.0), 4.0, 0), ((2.0, 5.0), 3.0, 1.0), ((3.0, 5.0), 4.0, 0), ((4.0, 5.0), 4.2, 0), ((5.0, 5.0), 4.6, 0), ((6.0, 5.0), 5.0, 0), ] current = [(n, G.node[n]['obj'].z, G.node[n]['obj'].flooded) for n in sorted(G.node)] self.assertEqual(sorted(target), current)
def test000(self): """ A---B---C---D---E---F levels: 5 6 5 4 6 8 result: 0 0 1 2 0 0 """ G = nx.Graph() nodes = [("A", Put(coords=(0, 0, 5))), ("B", Put(coords=(0, 1, 6))), ("C", Put(coords=(0, 2, 5))), ("D", Put(coords=(0, 3, 4))), ("E", Put(coords=(0, 4, 6))), ("F", Put(coords=(0, 5, 8)))] for label, obj in nodes: G.add_node(label, obj=obj) for (p, x), (c, y) in zip(nodes, nodes[1:]): G.add_edge(p, c) compute_lost_water_depth(G, "A") self.assertEqual(0, G.node["A"]['obj'].flooded) self.assertEqual(0, G.node["B"]['obj'].flooded) self.assertEqual(1, G.node["C"]['obj'].flooded) self.assertEqual(2, G.node["D"]['obj'].flooded) self.assertEqual(0, G.node["E"]['obj'].flooded) self.assertEqual(0, G.node["F"]['obj'].flooded)
def test100(self): "watering a complex network" pool = {} G = nx.Graph() parse("lizard_riool/data/4F1 asfalt werk.RMB", pool) convert_to_graph(pool, G) compute_lost_water_depth(G, (138736.31, 485299.37))
def test200(self): "watering a simple network, ZYB == 2 strings" pool = {} G = nx.Graph() parse("lizard_riool/data/f3478_2zyb2.rmb", pool) convert_to_graph(pool, G) # sink = node 1 of Riool 6400001 = 64D0001 sink = tuple(pool['6400001'][0].point(1, False)[:2]) compute_lost_water_depth(G, sink) target = [0, 0, 0] current = [ pool['6400001'][1].flooded, pool['6400001'][2].flooded, pool['6400001'][3].flooded ] self.assertEqual(target, current)