Skip to content

Commit

Permalink
Generate test picture
Browse files Browse the repository at this point in the history
  • Loading branch information
donRumata03 committed Apr 21, 2024
1 parent 22fd62b commit b723d98
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/unit-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,10 @@ jobs:
- name: Test with pytest
run: |
pytest --cov=golem test/unit
- name: Upload graph layout as an artifact
uses: actions/upload-artifact@v2
with:
name: graph-layout
path: 'test/unit/visualisation/graph_layout.png'
- name: Codecov-coverage
uses: codecov/codecov-action@v2
15 changes: 15 additions & 0 deletions test/unit/visualisation/test_visualisation_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import pathlib

from matplotlib import pyplot as plt

from golem.core.adapter import DirectAdapter
from golem.core.dag.convert import graph_structure_as_nx_graph
from golem.core.optimisers.fitness.multi_objective_fitness import MultiObjFitness
Expand Down Expand Up @@ -44,6 +48,17 @@ def test_hierarchy_pos():
node_labels = {uid: str(node) for uid, node in nodes_dict.items()}

pos = GraphVisualizer._get_hierarchy_pos_by_distance_to_primary_level(nx_graph, nodes_dict)
pos_by_label = {node_labels[uid]: pos[uid] for uid in pos}
print("pos_by_label:", pos_by_label)
descriptive_id = {nodes_dict[uid].descriptive_id: uid for uid in nodes_dict}
print("descriptive_id:", descriptive_id)
this_dir = pathlib.Path(__file__).parent

GraphVisualizer(graph).visualise(
nodes_layout_function=GraphVisualizer._get_hierarchy_pos_by_distance_to_primary_level,
save_path=this_dir / "graph_layout.png"
)

print("pos:", pos)
comparable_lists_y = make_comparable_lists(pos, real_hierarchy_levels_y,
node_labels, 1, reverse=True)
Expand Down

0 comments on commit b723d98

Please sign in to comment.