From 16170169f5a6e46a2f89ae1b8d283a3514cecb20 Mon Sep 17 00:00:00 2001 From: "h0an.le" Date: Thu, 26 Sep 2024 15:25:03 +0200 Subject: [PATCH] code revision --- app/common.py | 1 + app/visualisation.py | 4 +++- examples/ex_loading_saved_files.py | 1 + tests/test_2_loading_saved_files.py | 1 - 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/common.py b/app/common.py index 1db8faf..bc9f1ce 100644 --- a/app/common.py +++ b/app/common.py @@ -1635,6 +1635,7 @@ def save(self, fname=None): def set_attributes(self, attributes_dict): """Set attributes of the Graph object from a given dictionary.""" + for key, value in attributes_dict.items(): if hasattr(self, key): setattr(self, key, value) diff --git a/app/visualisation.py b/app/visualisation.py index 7676990..f6466c1 100644 --- a/app/visualisation.py +++ b/app/visualisation.py @@ -799,6 +799,7 @@ def load(self, file_path): for graph_id, graph_data in plots_data.items(): # Recreate graph instance graph = Graph(graph_id=graph_id) + graph.filters = graph_data.get('filters', []) graph.set_attributes(graph_data) # Plot the graph @@ -833,7 +834,8 @@ def load(self, file_path): self.add_graph_list_to_combobox() except Exception as e: - print(f"Error loading work: {e}") + show_alert(f"Error loading saved work (Visulization Tab): {e}") + # print(f"Error loading work: {e}") def delete_graph(self, graph_id): """Delete the specified graph from the plots dictionary by graph_id""" diff --git a/examples/ex_loading_saved_files.py b/examples/ex_loading_saved_files.py index 709cd79..f8aed3b 100644 --- a/examples/ex_loading_saved_files.py +++ b/examples/ex_loading_saved_files.py @@ -1,6 +1,7 @@ import sys import os from pathlib import Path +import pytest from PySide6.QtWidgets import QApplication from PySide6.QtGui import QIcon diff --git a/tests/test_2_loading_saved_files.py b/tests/test_2_loading_saved_files.py index 229b2a6..68312b2 100644 --- a/tests/test_2_loading_saved_files.py +++ b/tests/test_2_loading_saved_files.py @@ -1,4 +1,3 @@ -# Test_1 import sys from pathlib import Path