Removed double execution of Layouting in 2 and 3d. (#385)

Prior to layouting the sping layout was allways calculated and later
overwritten. (Double execution)
This commit is contained in:
2023-11-16 17:25:15 +01:00
committed by GitHub
parent 96d216fb74
commit ce1598c42e
5 changed files with 22 additions and 64 deletions

View File

@ -25,7 +25,19 @@ def _set_session(full_db: Session) -> Generator[None, None, None]:
SessionHandler.session = None
def test_create_2d_graph() -> None:
@pytest.mark.parametrize(
("layout", "metric", "edge_annotation", "edge_thickness"),
[
("Kamada Kawai", "None", True, 1),
("Random", "degree", False, 2),
("Shell", "degree", True, 3),
("Spiral", "None", False, 4),
("Circular", "None", True, 1),
],
)
def test_create_2d_graph(
layout: str, metric: str, edge_annotation: bool, edge_thickness: int
) -> None:
"""Tests the creation of a 2D Graph."""
edges: list = [
{"from": "p_545", "to": "c_53", "type": "HAFTENDER_GESELLSCHAFTER"},
@ -61,42 +73,6 @@ def test_create_2d_graph() -> None:
},
}
graph, metrics = initialize_network(edges=edges, nodes=nodes)
metric = "None"
layout = "Spring"
edge_annotation = False
edge_thickness = 1
figure = create_2d_graph(
graph, nodes, edges, metrics, metric, layout, edge_annotation, edge_thickness
)
assert type(figure) is go.Figure
metric = "degree"
layout = "Circular"
figure = create_2d_graph(
graph, nodes, edges, metrics, metric, layout, edge_annotation, edge_thickness
)
assert type(figure) is go.Figure
edge_annotation = True
layout = "Kamada Kawai"
figure = create_2d_graph(
graph, nodes, edges, metrics, metric, layout, edge_annotation, edge_thickness
)
assert type(figure) is go.Figure
layout = "Random"
figure = create_2d_graph(
graph, nodes, edges, metrics, metric, layout, edge_annotation, edge_thickness
)
assert type(figure) is go.Figure
layout = "Shell (only 2D)"
figure = create_2d_graph(
graph, nodes, edges, metrics, metric, layout, edge_annotation, edge_thickness
)
assert type(figure) is go.Figure
layout = "Spiral (only 2D)"
figure = create_2d_graph(
graph, nodes, edges, metrics, metric, layout, edge_annotation, edge_thickness
)

View File

@ -228,7 +228,6 @@ def test_get_all_metrics_from_id() -> None:
def test_get_relations_number_from_id() -> None:
"""This Test methods tests if the correct type and number of relations is received."""
# id = "c_2549"
id = 2
(
relations_lvl_1,