mg-pso-gui 0.1.40__py3-none-any.whl → 0.2.75__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. {mg_pso_gui-0.1.40.dist-info → mg_pso_gui-0.2.75.dist-info}/METADATA +10 -11
  2. mg_pso_gui-0.2.75.dist-info/RECORD +76 -0
  3. {mg_pso_gui-0.1.40.dist-info → mg_pso_gui-0.2.75.dist-info}/WHEEL +1 -1
  4. mgpsogui/gui/General/ParameterView.py +110 -0
  5. mgpsogui/gui/General/__init__.py +0 -0
  6. mgpsogui/gui/HomePage.py +234 -238
  7. mgpsogui/gui/OptionManager.py +333 -145
  8. mgpsogui/gui/OptionManager_backup.py +443 -0
  9. mgpsogui/gui/PlatformTab/PlatformTab.py +15 -6
  10. mgpsogui/gui/RunTab/OptimalParameterView.py +47 -0
  11. mgpsogui/gui/RunTab/RunTab.py +90 -17
  12. mgpsogui/gui/SetupTab/BoundsEditorWindow.py +1 -1
  13. mgpsogui/gui/SetupTab/BoundsList.py +97 -34
  14. mgpsogui/gui/SetupTab/CustomFunctionEditorWindow.py +74 -0
  15. mgpsogui/gui/SetupTab/CustomFunctionMetrics.py +156 -0
  16. mgpsogui/gui/SetupTab/FunctionsList.py +60 -6
  17. mgpsogui/gui/SetupTab/{StaticParameterView.py → ListEditor.py} +27 -16
  18. mgpsogui/gui/SetupTab/ListParametersView.py +7 -6
  19. mgpsogui/gui/SetupTab/{CalibrationParametersView.py → OverrideParameterMetrics.py} +35 -9
  20. mgpsogui/gui/SetupTab/OverrideParameterWindow.py +40 -0
  21. mgpsogui/gui/SetupTab/SetupTab.py +31 -11
  22. mgpsogui/gui/SetupTab/StepView.py +93 -22
  23. mgpsogui/gui/VisualizeTab/MatrixEditor.py +68 -0
  24. mgpsogui/gui/VisualizeTab/SideBar.py +316 -25
  25. mgpsogui/gui/VisualizeTab/VisualizeTab.py +69 -8
  26. mgpsogui/gui/defaults/__init__.py +0 -0
  27. mgpsogui/gui/defaults/optimization.json +176 -0
  28. mgpsogui/gui/defaults/sampling.json +111 -0
  29. mgpsogui/gui/defaults/sensitivity.json +20 -0
  30. mgpsogui/gui/images/plus.png +0 -0
  31. mgpsogui/util/GraphGenerator.py +721 -50
  32. mgpsogui/util/PSORunner.py +615 -86
  33. mgpsogui/util/debug.py +559 -0
  34. mgpsogui/util/helpers.py +95 -0
  35. mgpsogui/util/recosu/__init__.py +2 -1
  36. mgpsogui/util/recosu/pso/pso.py +55 -11
  37. mgpsogui/util/recosu/sampling/__init__.py +16 -0
  38. mgpsogui/util/recosu/sampling/halton/__init__.py +0 -0
  39. mgpsogui/util/recosu/sampling/halton/halton.py +45 -0
  40. mgpsogui/util/recosu/sampling/halton/prime.py +82 -0
  41. mgpsogui/util/recosu/sampling/random/__init__.py +0 -0
  42. mgpsogui/util/recosu/sampling/random/random_sampler.py +34 -0
  43. mgpsogui/util/recosu/sampling/sample_trace_writer.py +47 -0
  44. mgpsogui/util/recosu/sampling/sampler_task.py +75 -0
  45. mgpsogui/util/recosu/sampling/sampling.py +99 -0
  46. mgpsogui/util/sampler_test_driver.py +129 -0
  47. mg_pso_gui-0.1.40.dist-info/RECORD +0 -52
  48. mgpsogui/gui/images/IGOW 4 Logo.png +0 -0
  49. {mg_pso_gui-0.1.40.dist-info → mg_pso_gui-0.2.75.dist-info}/entry_points.txt +0 -0
  50. {mg_pso_gui-0.1.40.dist-info → mg_pso_gui-0.2.75.dist-info}/top_level.txt +0 -0
@@ -9,6 +9,8 @@ from customtkinter import CTkOptionMenu
9
9
  from PIL import Image
10
10
  import os
11
11
 
12
+ from . import MatrixEditor as me
13
+
12
14
  import pandas as pd
13
15
 
14
16
  class SideBar(CTkScrollableFrame):
@@ -37,27 +39,168 @@ class SideBar(CTkScrollableFrame):
37
39
  0, 0), pady=(0, 0), sticky="ew")
38
40
  self.containerFrame.grid_columnconfigure(0, weight=1)
39
41
 
40
- selected_graph = self.home_page.graph_selector_value.get()
42
+ selected_graph = self.option_manager.get("selected_graph").get()
41
43
 
42
44
  if (selected_graph == "Best Cost Stacked"):
43
- self.graph_label = CTkLabel(self.containerFrame, text="Best Cost Stacked")
44
- self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
45
+ #self.graph_label = CTkLabel(self.containerFrame, text="Best Cost Stacked")
46
+ #self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
45
47
  pass
46
48
  elif (selected_graph == "Best Cost by Round"):
47
- self.graph_label = CTkLabel(self.containerFrame, text="Best Cost by Round")
48
- self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
49
+ #self.graph_label = CTkLabel(self.containerFrame, text="Best Cost by Round")
50
+ #self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
49
51
  pass
50
52
  elif (selected_graph == "Iteration Table"):
51
- self.graph_label = CTkLabel(self.containerFrame, text="Iteration Table")
52
- self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
53
+ #self.graph_label = CTkLabel(self.containerFrame, text="Iteration Table")
54
+ #self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
53
55
  pass
54
56
  elif (selected_graph == "Calibrated Parameters"):
55
- self.graph_label = CTkLabel(self.containerFrame, text="Calibrated Parameters")
56
- self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
57
+ #self.graph_label = CTkLabel(self.containerFrame, text="Calibrated Parameters")
58
+ #self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
59
+ pass
57
60
  elif (selected_graph == "Custom CSV"):
58
61
 
59
- info = self.option_manager.get_project_data()
60
- folder = os.path.join(info['path'], info['name'])
62
+ folder = self.option_manager.get_project_folder()
63
+ if not os.path.exists(folder):
64
+ os.makedirs(folder)
65
+
66
+ # Get all CSV files in the folder and add their paths to a list
67
+ path_map = {}
68
+ name_list = []
69
+ for root, dirs, files in os.walk(folder):
70
+ for file in files:
71
+ if file.endswith(".csv"):
72
+ name = file.replace(".csv", "")
73
+ name_list.append(name)
74
+ path_map[name] = os.path.join(root, file)
75
+
76
+ if (len(name_list) == 0):
77
+ name_list.append("No files found...")
78
+ else:
79
+ if (self.option_manager.get("selected_csv").get() not in name_list):
80
+ self.option_manager.get("selected_csv").set(name_list[0])
81
+
82
+ file_label = CTkLabel(self.containerFrame, text="CSV File:")
83
+ file_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
84
+
85
+ self.home_page.csv_file_selector = CTkOptionMenu(self.containerFrame, values=name_list, variable=self.option_manager.get("selected_csv"), command=self.home_page.update_graph)
86
+ self.home_page.csv_file_selector.grid(row=1, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
87
+
88
+ selected_file = self.option_manager.get("selected_csv").get()
89
+ if (selected_file in path_map and selected_file != self.home_page.open_file):
90
+ self.home_page.csv_data = self.load_special_csv(path_map[selected_file])
91
+ print(self.home_page.csv_data)
92
+ self.home_page.open_file = selected_file
93
+
94
+ if (self.home_page.csv_data is not None):
95
+ # Get all column names of CSV
96
+ columns = self.home_page.csv_data["data"].columns
97
+
98
+ x_axis_label = CTkLabel(self.containerFrame, text="X Axis:")
99
+ x_axis_label.grid(row=2, column=0, padx=(20, 20), pady=(40, 5), sticky="w")
100
+
101
+ self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_x"), command=self.home_page.update_graph)
102
+ self.home_page.csv_x_selector.grid(row=3, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
103
+
104
+ if (self.home_page.csv_x_selector.get() not in columns):
105
+ self.home_page.csv_x_selector.set(columns[1])
106
+
107
+ y1_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
108
+ y1_axis_label.grid(row=4, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
109
+
110
+ self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y1"), command=self.home_page.update_graph)
111
+ self.home_page.csv_y1_selector.grid(row=5, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
112
+
113
+ if (self.home_page.csv_y1_selector.get() not in columns):
114
+ self.home_page.csv_y1_selector.set(columns[2])
115
+
116
+ y2_axis_label = CTkLabel(self.containerFrame, text="Secondary Y Axis:")
117
+ y2_axis_label.grid(row=6, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
118
+
119
+ self.home_page.csv_y2_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y2"), command=self.home_page.update_graph)
120
+ self.home_page.csv_y2_selector.grid(row=7, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
121
+
122
+ if (self.home_page.csv_y2_selector.get() not in columns):
123
+ self.home_page.csv_y2_selector.set(columns[3])
124
+
125
+ elif (selected_graph == "Compare CSV"):
126
+ folder = self.option_manager.get_project_folder()
127
+ if not os.path.exists(folder):
128
+ os.makedirs(folder)
129
+
130
+ # Get all CSV files in the folder and add their paths to a list
131
+ path_map = {}
132
+ name_list = []
133
+ for root, dirs, files in os.walk(folder):
134
+ for file in files:
135
+ if file.endswith(".csv"):
136
+ name = file.replace(".csv", "")
137
+ name_list.append(name)
138
+ path_map[name] = os.path.join(root, file)
139
+
140
+ if (len(name_list) == 0):
141
+ name_list.append("No files found...")
142
+ else:
143
+ if (self.option_manager.get("selected_csv").get() not in name_list):
144
+ self.option_manager.get("selected_csv").set(name_list[0])
145
+ if (self.option_manager.get("selected_csv2").get() not in name_list):
146
+ self.option_manager.get("selected_csv2").set(name_list[0])
147
+
148
+ file_label = CTkLabel(self.containerFrame, text="CSV Files:")
149
+ file_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
150
+
151
+ self.home_page.csv_file_selector = CTkOptionMenu(self.containerFrame, values=name_list, variable=self.option_manager.get("selected_csv"), command=self.home_page.update_graph)
152
+ self.home_page.csv_file_selector.grid(row=1, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
153
+
154
+ self.home_page.csv_file_selector2 = CTkOptionMenu(self.containerFrame, values=name_list, variable=self.option_manager.get("selected_csv2"), command=self.home_page.update_graph)
155
+ self.home_page.csv_file_selector2.grid(row=2, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
156
+
157
+ selected_file = self.option_manager.get("selected_csv").get()
158
+ if (selected_file in path_map and selected_file != self.home_page.open_file):
159
+ self.home_page.csv_data = self.load_special_csv(path_map[selected_file])
160
+ print(self.home_page.csv_data)
161
+ self.home_page.open_file = selected_file
162
+
163
+ selected_file2 = self.option_manager.get("selected_csv2").get()
164
+ if (selected_file2 in path_map and selected_file2 != self.home_page.open_file2):
165
+ self.home_page.csv_data2 = self.load_special_csv(path_map[selected_file2])
166
+ print(self.home_page.csv_data2)
167
+ self.home_page.open_file2 = selected_file2
168
+
169
+ if (self.home_page.csv_data is not None and self.home_page.csv_data2 is not None):
170
+ # Get all column names of CSV
171
+ columns = self.home_page.csv_data["data"].columns
172
+ columns2 = self.home_page.csv_data2["data"].columns
173
+
174
+ x_axis_label = CTkLabel(self.containerFrame, text="X Axis:")
175
+ x_axis_label.grid(row=3, column=0, padx=(20, 20), pady=(40, 5), sticky="w")
176
+
177
+ self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_x"), command=self.home_page.update_graph)
178
+ self.home_page.csv_x_selector.grid(row=4, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
179
+
180
+ if (self.home_page.csv_x_selector.get() not in columns):
181
+ self.home_page.csv_x_selector.set(columns[1])
182
+
183
+ y1_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
184
+ y1_axis_label.grid(row=5, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
185
+
186
+ self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y1"), command=self.home_page.update_graph)
187
+ self.home_page.csv_y1_selector.grid(row=6, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
188
+
189
+ if (self.home_page.csv_y1_selector.get() not in columns):
190
+ self.home_page.csv_y1_selector.set(columns[2])
191
+
192
+ y2_axis_label = CTkLabel(self.containerFrame, text="Secondary Y Axis:")
193
+ y2_axis_label.grid(row=7, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
194
+
195
+ self.home_page.csv_y2_selector = CTkOptionMenu(self.containerFrame, values=columns2, variable=self.option_manager.get("selected_y2"), command=self.home_page.update_graph)
196
+ self.home_page.csv_y2_selector.grid(row=8, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
197
+
198
+ if (self.home_page.csv_y2_selector.get() not in columns2):
199
+ self.home_page.csv_y2_selector.set(columns2[2])
200
+
201
+ elif (selected_graph == "Sampling CSV"):
202
+
203
+ folder = self.option_manager.get_project_folder()
61
204
  if not os.path.exists(folder):
62
205
  os.makedirs(folder)
63
206
 
@@ -74,35 +217,183 @@ class SideBar(CTkScrollableFrame):
74
217
  if (len(name_list) == 0):
75
218
  name_list.append("No files found...")
76
219
  else:
77
- if (self.home_page.selected_csv.get() not in name_list):
78
- self.home_page.selected_csv.set(name_list[0])
220
+ if (self.option_manager.get("selected_csv").get() not in name_list):
221
+ self.option_manager.get("selected_csv").set(name_list[0])
222
+
223
+ file_label = CTkLabel(self.containerFrame, text="CSV File:")
224
+ file_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
79
225
 
80
- self.home_page.csv_file_selector = CTkOptionMenu(self.containerFrame, values=name_list, variable=self.home_page.selected_csv, command=self.home_page.update_graph)
81
- self.home_page.csv_file_selector.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
226
+ self.home_page.csv_file_selector = CTkOptionMenu(self.containerFrame, values=name_list, variable=self.option_manager.get("selected_csv"), command=self.home_page.update_graph)
227
+ self.home_page.csv_file_selector.grid(row=1, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
82
228
 
83
- selected_file = self.home_page.selected_csv.get()
229
+ selected_file = self.option_manager.get("selected_csv").get()
84
230
  if (selected_file in path_map and selected_file != self.home_page.open_file):
85
- self.home_page.csv_data = pd.read_csv(path_map[selected_file], skiprows=3)
231
+ self.home_page.csv_data = pd.read_csv(path_map[selected_file])
232
+ print(self.home_page.csv_data)
86
233
  self.home_page.open_file = selected_file
87
234
 
88
- if (self.home_page.csv_data != None):
235
+ if (self.home_page.csv_data is not None):
89
236
  # Get all column names of CSV
90
237
  columns = self.home_page.csv_data.columns
91
238
 
92
- self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.home_page.selected_x, command=self.home_page.update_graph)
93
- self.home_page.csv_x_selector.grid(row=2, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
239
+ x_axis_label = CTkLabel(self.containerFrame, text="X Axis:")
240
+ x_axis_label.grid(row=2, column=0, padx=(20, 20), pady=(40, 5), sticky="w")
241
+
242
+ self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_x"), command=self.home_page.update_graph)
243
+ self.home_page.csv_x_selector.grid(row=3, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
94
244
 
95
245
  if (self.home_page.csv_x_selector.get() not in columns):
96
246
  self.home_page.csv_x_selector.set(columns[1])
97
247
 
98
- self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.home_page.selected_y1, command=self.home_page.update_graph)
99
- self.home_page.csv_y1_selector.grid(row=2, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
248
+ y1_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
249
+ y1_axis_label.grid(row=4, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
250
+
251
+ self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y1"), command=self.home_page.update_graph)
252
+ self.home_page.csv_y1_selector.grid(row=5, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
100
253
 
101
254
  if (self.home_page.csv_y1_selector.get() not in columns):
102
255
  self.home_page.csv_y1_selector.set(columns[2])
103
256
 
104
- self.home_page.csv_y2_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.home_page.selected_y2, command=self.home_page.update_graph)
105
- self.home_page.csv_y2_selector.grid(row=2, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
257
+ y2_axis_label = CTkLabel(self.containerFrame, text="Secondary Y Axis:")
258
+ y2_axis_label.grid(row=6, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
259
+
260
+ self.home_page.csv_y2_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y2"), command=self.home_page.update_graph)
261
+ self.home_page.csv_y2_selector.grid(row=7, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
106
262
 
107
263
  if (self.home_page.csv_y2_selector.get() not in columns):
108
- self.home_page.csv_y2_selector.set(columns[3])
264
+ self.home_page.csv_y2_selector.set(columns[3])
265
+
266
+ style_label = CTkLabel(self.containerFrame, text="Figure Style:")
267
+ style_label.grid(row=8, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
268
+
269
+ self.home_page.figure_style_selector = CTkOptionMenu(self.containerFrame, values=["Scatter", "Bars", "Lines", "Area", "Box"], variable=self.option_manager.get("figure_style"), command=self.home_page.update_graph)
270
+ self.home_page.figure_style_selector.grid(row=9, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
271
+
272
+ elif (selected_graph == "Matrix Editor"):
273
+
274
+ folder = self.option_manager.get_project_folder()
275
+ if not os.path.exists(folder):
276
+ os.makedirs(folder)
277
+
278
+ # Get all CSV files in the folder and add their paths to a list
279
+ path_map = {}
280
+ name_list = []
281
+ for root, dirs, files in os.walk(folder):
282
+ for file in files:
283
+ if file.endswith(".csv"):
284
+ name = file.replace(".csv", "")
285
+ name_list.append(name)
286
+ path_map[name] = os.path.join(root, file)
287
+
288
+ if (len(name_list) == 0):
289
+ name_list.append("No files found...")
290
+ else:
291
+ if (self.option_manager.get("selected_csv").get() not in name_list):
292
+ self.option_manager.get("selected_csv").set(name_list[0])
293
+
294
+ file_label = CTkLabel(self.containerFrame, text="CSV File:")
295
+ file_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
296
+
297
+ self.home_page.csv_file_selector = CTkOptionMenu(self.containerFrame, values=name_list, variable=self.option_manager.get("selected_csv"), command=self.home_page.update_graph)
298
+ self.home_page.csv_file_selector.grid(row=1, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
299
+
300
+ selected_file = self.option_manager.get("selected_csv").get()
301
+ if (selected_file in path_map and selected_file != self.home_page.open_file):
302
+ self.home_page.csv_data = pd.read_csv(path_map[selected_file])
303
+ print(self.home_page.csv_data)
304
+ self.home_page.open_file = selected_file
305
+
306
+ if (self.home_page.csv_data is not None):
307
+ # Get all column names of CSV
308
+ columns = self.home_page.csv_data.columns
309
+
310
+ style_label = CTkLabel(self.containerFrame, text="Figure Style:")
311
+ style_label.grid(row=2, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
312
+
313
+ self.home_page.figure_style_selector = CTkOptionMenu(self.containerFrame, values=["Scatter", "Bars", "Lines", "Area", "Box"], variable=self.option_manager.get("figure_style"), command=self.home_page.update_graph)
314
+ self.home_page.figure_style_selector.grid(row=3, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
315
+
316
+ x_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
317
+ x_axis_label.grid(row=4, column=0, padx=(20, 20), pady=(40, 5), sticky="w")
318
+
319
+ self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_x"), command=self.home_page.update_graph)
320
+ self.home_page.csv_x_selector.grid(row=5, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
321
+
322
+ if (self.home_page.csv_x_selector.get() not in columns):
323
+ self.home_page.csv_x_selector.set(columns[1])
324
+
325
+ self.matrix_editor = me.MatrixEditor(self.containerFrame, width=280, option_manager=self.option_manager, home_page=self.home_page, columns=columns)
326
+ self.matrix_editor.grid(row=6, column=0, padx=(10, 10), pady=(10, 0), sticky="nsew")
327
+ self.matrix_editor.grid_columnconfigure(0, weight=1)
328
+ self.matrix_editor.grid_rowconfigure(0, weight=1)
329
+
330
+
331
+ #y1_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
332
+ #y1_axis_label.grid(row=6, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
333
+
334
+ #self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y1"), command=self.home_page.update_graph)
335
+ #self.home_page.csv_y1_selector.grid(row=7, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
336
+
337
+ #if (self.home_page.csv_y1_selector.get() not in columns):
338
+ # self.home_page.csv_y1_selector.set(columns[2])
339
+
340
+ def load_special_csv(self, file_path):
341
+ file_metadata = {}
342
+ data_metadata = {}
343
+ mode = "file_metadata"
344
+ columns = []
345
+ data_lines = []
346
+
347
+ with open(file_path, "r") as file:
348
+ lines = file.readlines()
349
+
350
+ if (not lines[0].startswith("@")):
351
+ return {
352
+ "file_attributes": {},
353
+ "data_attributes": {},
354
+ "data": pd.read_csv(file_path)
355
+ }
356
+
357
+ for line in lines:
358
+ if (line.startswith("@H,")):
359
+ mode = "data_metadata"
360
+ columns = line.strip().rstrip(",").split(",")[1:]
361
+ continue
362
+ elif (line.startswith("@T,")):
363
+ mode = "file_metadata"
364
+ continue
365
+ elif (line.startswith(",") and mode == "data_metadata"):
366
+ mode = "file_data"
367
+
368
+ if (mode == "file_metadata"):
369
+ try:
370
+ key, value = line.strip().rstrip(",").split(",")
371
+ file_metadata[key] = value
372
+ except:
373
+ pass
374
+
375
+ elif (mode == "data_metadata"):
376
+ try:
377
+ values = line.strip().rstrip(",").split(",")
378
+ key = values[0]
379
+ values = values[1:]
380
+ if len(values) == len(columns):
381
+ data_metadata[key] = {}
382
+ for i in range(len(columns)):
383
+ data_metadata[key][columns[i]] = values[i]
384
+ except:
385
+ pass
386
+
387
+ elif (mode == "file_data"):
388
+ try:
389
+ values = line.strip().rstrip(",").split(",")[1:]
390
+ if len(values) == len(columns):
391
+ data_lines.append(values)
392
+ except:
393
+ pass
394
+
395
+ return {
396
+ "file_attributes": file_metadata,
397
+ "data_attributes": data_metadata,
398
+ "data": pd.DataFrame(data_lines, columns=columns)
399
+ }
@@ -4,6 +4,7 @@ from PIL import Image, ImageTk
4
4
  import os
5
5
  import platform
6
6
  import subprocess
7
+ import shutil
7
8
 
8
9
  from . import SideBar
9
10
 
@@ -11,8 +12,7 @@ def create_tab(self, tab):
11
12
 
12
13
  def open_graph_in_browser():
13
14
  # Open the file in the default program
14
- info = self.option_manager.get_project_data()
15
- folder = os.path.join(info['path'], info['name'])
15
+ folder = self.option_manager.get_project_folder()
16
16
 
17
17
  if not os.path.exists(folder):
18
18
  os.makedirs(folder)
@@ -25,7 +25,62 @@ def create_tab(self, tab):
25
25
  subprocess.Popen(["open", file_path])
26
26
  else:
27
27
  subprocess.Popen(["xdg-open", file_path])
28
-
28
+
29
+ def export_graph():
30
+
31
+ folder = self.option_manager.get_project_folder()
32
+
33
+ if not os.path.exists(folder):
34
+ os.makedirs(folder)
35
+
36
+ html_file = os.path.join(folder, self.selected_graph_name + ".html")
37
+ json_file = os.path.join(folder, self.selected_graph_name + ".json")
38
+ png_file = os.path.join(folder, self.selected_graph_name + ".png")
39
+ pdf_file = os.path.join(folder, self.selected_graph_name + ".pdf")
40
+
41
+ # Make a directory call package
42
+ if not os.path.exists(os.path.join(folder, self.selected_graph_name + "_package")):
43
+ os.makedirs(os.path.join(folder, self.selected_graph_name + "_package"))
44
+
45
+ # Check if html_file exists and copy it to the package directory
46
+ if os.path.exists(html_file):
47
+ with open(html_file, 'r') as file:
48
+ data = file.read()
49
+ with open(os.path.join(folder, self.selected_graph_name + "_package", self.selected_graph_name + ".html"), 'w') as new_file:
50
+ new_file.write(data)
51
+
52
+ # Check if json_file exists and copy it to the package directory
53
+ if os.path.exists(json_file):
54
+ with open(json_file, 'r') as file:
55
+ data = file.read()
56
+ with open(os.path.join(folder, self.selected_graph_name + "_package", self.selected_graph_name + ".json"), 'w') as new_file:
57
+ new_file.write(data)
58
+
59
+ # Check if png_file exists and copy it to the package directory
60
+ if os.path.exists(png_file):
61
+ with open(png_file, 'rb') as file:
62
+ data = file.read()
63
+ with open(os.path.join(folder, self.selected_graph_name + "_package", self.selected_graph_name + ".png"), 'wb') as new_file:
64
+ new_file.write(data)
65
+
66
+ # Check if pdf_file exists and copy it to the package directory
67
+ if os.path.exists(pdf_file):
68
+ with open(pdf_file, 'rb') as file:
69
+ data = file.read()
70
+ with open(os.path.join(folder, self.selected_graph_name + "_package", self.selected_graph_name + ".pdf"), 'wb') as new_file:
71
+ new_file.write(data)
72
+
73
+ # Zip the package directory
74
+ shutil.make_archive(os.path.join(folder, self.selected_graph_name + "_package"), 'zip', os.path.join(folder, self.selected_graph_name + "_package"))
75
+
76
+ # Open the directory containing the package
77
+ if platform.system() == "Windows":
78
+ os.startfile(os.path.join(folder, self.selected_graph_name + "_package"))
79
+ elif platform.system() == "Darwin":
80
+ subprocess.Popen(["open", os.path.join(folder, self.selected_graph_name + "_package")])
81
+ else:
82
+ subprocess.Popen(["xdg-open", os.path.join(folder, self.selected_graph_name + "_package")])
83
+
29
84
  def _resize_image(event):
30
85
  self.graph_label.update_idletasks()
31
86
  new_width = self.graph_label.winfo_width()
@@ -61,20 +116,26 @@ def create_tab(self, tab):
61
116
  self.graph_container.grid_columnconfigure(0, weight=1)
62
117
  self.graph_container.grid_rowconfigure(0, weight=1)
63
118
 
64
- self.graph_selector = customtkinter.CTkOptionMenu(self.graph_sidebar, values=["Best Cost Stacked", "Best Cost by Round", "Calibrated Parameters", "Iteration Table", "Custom CSV"], variable=self.graph_selector_value, command=self.update_graph)
119
+ graph_types = []
120
+ self.graph_selector = customtkinter.CTkOptionMenu(self.graph_sidebar, values=graph_types, variable=self.option_manager.get("selected_graph"), command=self.update_graph)
65
121
  self.graph_selector.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
66
122
 
67
123
  # Create SideBar
68
124
  self.vis_sidebar = SideBar.SideBar(self.graph_sidebar, option_manager=self.option_manager, home_page=self, fg_color="transparent")
69
- self.vis_sidebar.grid(row=1, column=0, rowspan=8, padx=(0, 0), pady=(0, 0), sticky="nsew")
125
+ self.vis_sidebar.grid(row=1, column=0, rowspan=6, padx=(0, 0), pady=(0, 0), sticky="nsew")
70
126
 
127
+
128
+ self.graph_theme = customtkinter.CTkOptionMenu(self.graph_sidebar, values=["Dark", "Light", "Publication"], variable=self.option_manager.get("graph_theme"), command=self.update_graph)
129
+ self.graph_theme.grid(row=7, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
130
+
131
+ self.graph_export = customtkinter.CTkButton(self.graph_sidebar, text="Export", command=export_graph)
132
+ self.graph_export.grid(row=8, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
133
+
71
134
  # Add a button to call open_graph_in_browser
72
- self.graph_button = customtkinter.CTkButton(self.graph_sidebar, text="Open in Browser", command=open_graph_in_browser)
135
+ self.graph_button = customtkinter.CTkButton(self.graph_sidebar, text="Preview", command=open_graph_in_browser)
73
136
  self.graph_button.grid(row=9, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
74
137
 
75
138
  self.graph_image_obj = Image.open(os.path.join("./images", "refresh_hd.png"))
76
139
  self.graph_image = customtkinter.CTkImage(self.graph_image_obj, size=(1280, 720))
77
140
  self.graph_label = customtkinter.CTkLabel(self.graph_container, text=None, image=self.graph_image)
78
141
  self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
79
- #window = customtkinter.CTk()
80
- #self.graph_label.bind('<Configure>', _resize_image)
File without changes