Doppelte / Redundante Unittests entfernt

This commit is contained in:
2025-05-27 08:27:14 +02:00
parent 4100eba906
commit b18266e8e7
+5 -30
View File
@@ -267,7 +267,7 @@ class Anlage():
"""
def __init__(self, tol_snap=200.0, snap_step=10.0, tol_connect=1000.0, tol_connect_step=50.0):
def __init__(self, tol_snap=200.0, snap_step=10.0, tol_connect=5000.0, tol_connect_step=50.0):
# Container für alle Racks
self._racks = RackIDs(tol_snap=tol_snap)
# zuordnung zwischen KnotenID und Punkt
@@ -744,7 +744,7 @@ class TestPlant(unittest.TestCase):
self.assertEqual(plist1, [Point(0, 0), Point(0, 10)])
self.assertEqual(plist2, [Point(0, 0), Point(0,1), Point(0, 10)])
def test_add_equipment_w_tree(self):
def test_add_equipment_str_tree(self):
racks = {'Rack_1': [Point(0, 0), Point(0, 10)],
'Rack_2': [Point(10, -2), Point(10, 5)],
@@ -772,31 +772,8 @@ class TestPlant(unittest.TestCase):
self.assertEqual(plist1, [Point(0, 0), Point(0, 1), Point(0, 3), Point(0, 9), Point(0, 10)])
self.assertEqual(plist2, [Point(10, -2), Point(10, 0), Point(10, 2), Point(10, 3), Point(10, 5)])
def test_wegsuche_str_tree(self):
# Beispiel-Daten
points = [Point(x, y) for x, y in [(1, 2), (3, 4), (5, 5), (7, 8)]]
lines = [LineString([(0, 1), (2, 3)]), LineString([(4, 4), (6, 6)]), LineString([(8, 8), (10, 10)])]
# STRtree erstellen mit tatsächlichen LineStrings
tree = STRtree(lines)
# Zuordnung
nearest_line_for_point = {}
for point in points:
candidates = tree.query(point) # Gibt direkt LineStrings zurück
if not candidates:
continue
candidates = [lines[idx] for idx in candidates]
nearest_line = min(candidates, key=lambda line: line.distance(point))
nearest_line_for_point[point] = nearest_line
# Ausgabe
for point, line in nearest_line_for_point.items():
print(f"Punkt {point} liegt am nächsten zu Linie {line}")
def test_wegsuche_w_tree(self):
racks = {'Rack_1-0': [Point(0, 0), Point(0, 10)],
'Rack_2-0': [Point(10, -2), Point(10, 5)],
'Rack_2-1': [Point(0, 3), Point(10, 3)]}
@@ -884,7 +861,7 @@ class TestPlant(unittest.TestCase):
nx.draw(G3, pos, with_labels=False, node_size=10, font_size=8, edge_color=edge_colors)
plt.show()
def test_Wegsuche(self):
''' Erstellt Graphen mit Racks, Sensoren und Unterverteilern und sucht kürzeste Wege von Unterverteiler zu zugehörigen Sensoren'''
rack_segs = {'Rack_1': [Point(0, 0), Point(0, 10)],
@@ -951,11 +928,9 @@ if __name__ == '__main__':
suite.addTest(TestPlant('test_ids_to_point'))
suite.addTest(TestPlant('test_add_point_interim'))
suite.addTest(TestPlant('test_add_sensor'))
suite.addTest(TestPlant('test_add_equipment_w_tree'))
suite.addTest(TestPlant('test_add_equipment_str_tree'))
suite.addTest(TestPlant('test_wegsuche_str_tree'))
suite.addTest(TestPlant('test_wegsuche_w_tree'))
suite.addTest(TestPlant('test_generate_graph'))
suite.addTest(TestPlant('test_Wegsuche'))
runner = unittest.TextTestRunner()
runner.run(suite)
#unittest.main()