mg-pso-gui 0.1.40__py3-none-any.whl → 0.2.76__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.76.dist-info}/METADATA +10 -11
  2. mg_pso_gui-0.2.76.dist-info/RECORD +76 -0
  3. {mg_pso_gui-0.1.40.dist-info → mg_pso_gui-0.2.76.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 +358 -61
  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.76.dist-info}/entry_points.txt +0 -0
  50. {mg_pso_gui-0.1.40.dist-info → mg_pso_gui-0.2.76.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,72 +39,367 @@ 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()
41
-
42
- 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
- pass
46
- 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
- pass
50
- 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
- pass
54
- 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
- elif (selected_graph == "Custom CSV"):
58
-
59
- info = self.option_manager.get_project_data()
60
- folder = os.path.join(info['path'], info['name'])
61
- if not os.path.exists(folder):
62
- os.makedirs(folder)
63
-
64
- # Get all CSV files in the folder and add their paths to a list
65
- path_map = {}
66
- name_list = []
67
- for root, dirs, files in os.walk(folder):
68
- for file in files:
69
- if file.endswith(".csv"):
70
- name = file.replace(".csv", "")
71
- name_list.append(name)
72
- path_map[name] = os.path.join(root, file)
73
-
74
- if (len(name_list) == 0):
75
- name_list.append("No files found...")
76
- else:
77
- if (self.home_page.selected_csv.get() not in name_list):
78
- self.home_page.selected_csv.set(name_list[0])
79
-
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")
42
+ try:
43
+ self.option_manager.get("selected_graph").set("Best Cost Stacked")
44
+
45
+ selected_graph = self.option_manager.get("selected_graph").get()
82
46
 
83
- selected_file = self.home_page.selected_csv.get()
84
- 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)
86
- self.home_page.open_file = selected_file
47
+ if (selected_graph == "Best Cost Stacked"):
48
+ #self.graph_label = CTkLabel(self.containerFrame, text="Best Cost Stacked")
49
+ #self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
50
+ pass
51
+ elif (selected_graph == "Best Cost by Round"):
52
+ #self.graph_label = CTkLabel(self.containerFrame, text="Best Cost by Round")
53
+ #self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
54
+ pass
55
+ elif (selected_graph == "Iteration Table"):
56
+ #self.graph_label = CTkLabel(self.containerFrame, text="Iteration Table")
57
+ #self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
58
+ pass
59
+ elif (selected_graph == "Calibrated Parameters"):
60
+ #self.graph_label = CTkLabel(self.containerFrame, text="Calibrated Parameters")
61
+ #self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
62
+ pass
63
+ elif (selected_graph == "Custom CSV"):
64
+
65
+ folder = self.option_manager.get_project_folder()
66
+ if not os.path.exists(folder):
67
+ os.makedirs(folder)
68
+
69
+ # Get all CSV files in the folder and add their paths to a list
70
+ path_map = {}
71
+ name_list = []
72
+ for root, dirs, files in os.walk(folder):
73
+ for file in files:
74
+ if file.endswith(".csv"):
75
+ name = file.replace(".csv", "")
76
+ name_list.append(name)
77
+ path_map[name] = os.path.join(root, file)
78
+
79
+ if (len(name_list) == 0):
80
+ name_list.append("No files found...")
81
+ else:
82
+ if (self.option_manager.get("selected_csv").get() not in name_list):
83
+ self.option_manager.get("selected_csv").set(name_list[0])
84
+
85
+ file_label = CTkLabel(self.containerFrame, text="CSV File:")
86
+ file_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
87
+
88
+ 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)
89
+ self.home_page.csv_file_selector.grid(row=1, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
90
+
91
+ selected_file = self.option_manager.get("selected_csv").get()
92
+ if (selected_file in path_map and selected_file != self.home_page.open_file):
93
+ self.home_page.csv_data = self.load_special_csv(path_map[selected_file])
94
+ print(self.home_page.csv_data)
95
+ self.home_page.open_file = selected_file
96
+
97
+ if (self.home_page.csv_data is not None):
98
+ # Get all column names of CSV
99
+ columns = self.home_page.csv_data["data"].columns
100
+
101
+ x_axis_label = CTkLabel(self.containerFrame, text="X Axis:")
102
+ x_axis_label.grid(row=2, column=0, padx=(20, 20), pady=(40, 5), sticky="w")
103
+
104
+ self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_x"), command=self.home_page.update_graph)
105
+ self.home_page.csv_x_selector.grid(row=3, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
106
+
107
+ if (self.home_page.csv_x_selector.get() not in columns):
108
+ self.home_page.csv_x_selector.set(columns[1])
109
+
110
+ y1_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
111
+ y1_axis_label.grid(row=4, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
112
+
113
+ self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y1"), command=self.home_page.update_graph)
114
+ self.home_page.csv_y1_selector.grid(row=5, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
115
+
116
+ if (self.home_page.csv_y1_selector.get() not in columns):
117
+ self.home_page.csv_y1_selector.set(columns[2])
118
+
119
+ y2_axis_label = CTkLabel(self.containerFrame, text="Secondary Y Axis:")
120
+ y2_axis_label.grid(row=6, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
121
+
122
+ self.home_page.csv_y2_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y2"), command=self.home_page.update_graph)
123
+ self.home_page.csv_y2_selector.grid(row=7, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
124
+
125
+ if (self.home_page.csv_y2_selector.get() not in columns):
126
+ self.home_page.csv_y2_selector.set(columns[3])
127
+
128
+ elif (selected_graph == "Compare CSV"):
129
+ folder = self.option_manager.get_project_folder()
130
+ if not os.path.exists(folder):
131
+ os.makedirs(folder)
132
+
133
+ # Get all CSV files in the folder and add their paths to a list
134
+ path_map = {}
135
+ name_list = []
136
+ for root, dirs, files in os.walk(folder):
137
+ for file in files:
138
+ if file.endswith(".csv"):
139
+ name = file.replace(".csv", "")
140
+ name_list.append(name)
141
+ path_map[name] = os.path.join(root, file)
142
+
143
+ if (len(name_list) == 0):
144
+ name_list.append("No files found...")
145
+ else:
146
+ if (self.option_manager.get("selected_csv").get() not in name_list):
147
+ self.option_manager.get("selected_csv").set(name_list[0])
148
+ if (self.option_manager.get("selected_csv2").get() not in name_list):
149
+ self.option_manager.get("selected_csv2").set(name_list[0])
150
+
151
+ file_label = CTkLabel(self.containerFrame, text="CSV Files:")
152
+ file_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
153
+
154
+ 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)
155
+ self.home_page.csv_file_selector.grid(row=1, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
87
156
 
88
- if (self.home_page.csv_data != None):
89
- # Get all column names of CSV
90
- columns = self.home_page.csv_data.columns
157
+ 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)
158
+ self.home_page.csv_file_selector2.grid(row=2, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
91
159
 
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")
160
+ selected_file = self.option_manager.get("selected_csv").get()
161
+ if (selected_file in path_map and selected_file != self.home_page.open_file):
162
+ self.home_page.csv_data = self.load_special_csv(path_map[selected_file])
163
+ print(self.home_page.csv_data)
164
+ self.home_page.open_file = selected_file
165
+
166
+ selected_file2 = self.option_manager.get("selected_csv2").get()
167
+ if (selected_file2 in path_map and selected_file2 != self.home_page.open_file2):
168
+ self.home_page.csv_data2 = self.load_special_csv(path_map[selected_file2])
169
+ print(self.home_page.csv_data2)
170
+ self.home_page.open_file2 = selected_file2
171
+
172
+ if (self.home_page.csv_data is not None and self.home_page.csv_data2 is not None):
173
+ # Get all column names of CSV
174
+ columns = self.home_page.csv_data["data"].columns
175
+ columns2 = self.home_page.csv_data2["data"].columns
176
+
177
+ x_axis_label = CTkLabel(self.containerFrame, text="X Axis:")
178
+ x_axis_label.grid(row=3, column=0, padx=(20, 20), pady=(40, 5), sticky="w")
179
+
180
+ self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_x"), command=self.home_page.update_graph)
181
+ self.home_page.csv_x_selector.grid(row=4, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
182
+
183
+ if (self.home_page.csv_x_selector.get() not in columns):
184
+ self.home_page.csv_x_selector.set(columns[1])
185
+
186
+ y1_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
187
+ y1_axis_label.grid(row=5, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
188
+
189
+ self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y1"), command=self.home_page.update_graph)
190
+ self.home_page.csv_y1_selector.grid(row=6, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
191
+
192
+ if (self.home_page.csv_y1_selector.get() not in columns):
193
+ self.home_page.csv_y1_selector.set(columns[2])
194
+
195
+ y2_axis_label = CTkLabel(self.containerFrame, text="Secondary Y Axis:")
196
+ y2_axis_label.grid(row=7, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
197
+
198
+ self.home_page.csv_y2_selector = CTkOptionMenu(self.containerFrame, values=columns2, variable=self.option_manager.get("selected_y2"), command=self.home_page.update_graph)
199
+ self.home_page.csv_y2_selector.grid(row=8, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
200
+
201
+ if (self.home_page.csv_y2_selector.get() not in columns2):
202
+ self.home_page.csv_y2_selector.set(columns2[2])
203
+
204
+ elif (selected_graph == "Sampling CSV"):
94
205
 
95
- if (self.home_page.csv_x_selector.get() not in columns):
96
- self.home_page.csv_x_selector.set(columns[1])
206
+ folder = self.option_manager.get_project_folder()
207
+ if not os.path.exists(folder):
208
+ os.makedirs(folder)
209
+
210
+ # Get all CSV files in the folder and add their paths to a list
211
+ path_map = {}
212
+ name_list = []
213
+ for root, dirs, files in os.walk(folder):
214
+ for file in files:
215
+ if file.endswith(".csv"):
216
+ name = file.replace(".csv", "")
217
+ name_list.append(name)
218
+ path_map[name] = os.path.join(root, file)
97
219
 
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")
220
+ if (len(name_list) == 0):
221
+ name_list.append("No files found...")
222
+ else:
223
+ if (self.option_manager.get("selected_csv").get() not in name_list):
224
+ self.option_manager.get("selected_csv").set(name_list[0])
100
225
 
101
- if (self.home_page.csv_y1_selector.get() not in columns):
102
- self.home_page.csv_y1_selector.set(columns[2])
226
+ file_label = CTkLabel(self.containerFrame, text="CSV File:")
227
+ file_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
103
228
 
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")
229
+ 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)
230
+ self.home_page.csv_file_selector.grid(row=1, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
106
231
 
107
- if (self.home_page.csv_y2_selector.get() not in columns):
108
- self.home_page.csv_y2_selector.set(columns[3])
232
+ selected_file = self.option_manager.get("selected_csv").get()
233
+ if (selected_file in path_map and selected_file != self.home_page.open_file):
234
+ self.home_page.csv_data = pd.read_csv(path_map[selected_file])
235
+ print(self.home_page.csv_data)
236
+ self.home_page.open_file = selected_file
237
+
238
+ if (self.home_page.csv_data is not None):
239
+ # Get all column names of CSV
240
+ columns = self.home_page.csv_data.columns
241
+
242
+ x_axis_label = CTkLabel(self.containerFrame, text="X Axis:")
243
+ x_axis_label.grid(row=2, column=0, padx=(20, 20), pady=(40, 5), sticky="w")
244
+
245
+ self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_x"), command=self.home_page.update_graph)
246
+ self.home_page.csv_x_selector.grid(row=3, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
247
+
248
+ if (self.home_page.csv_x_selector.get() not in columns):
249
+ self.home_page.csv_x_selector.set(columns[1])
250
+
251
+ y1_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
252
+ y1_axis_label.grid(row=4, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
253
+
254
+ self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y1"), command=self.home_page.update_graph)
255
+ self.home_page.csv_y1_selector.grid(row=5, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
256
+
257
+ if (self.home_page.csv_y1_selector.get() not in columns):
258
+ self.home_page.csv_y1_selector.set(columns[2])
259
+
260
+ y2_axis_label = CTkLabel(self.containerFrame, text="Secondary Y Axis:")
261
+ y2_axis_label.grid(row=6, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
262
+
263
+ self.home_page.csv_y2_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y2"), command=self.home_page.update_graph)
264
+ self.home_page.csv_y2_selector.grid(row=7, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
265
+
266
+ if (self.home_page.csv_y2_selector.get() not in columns):
267
+ self.home_page.csv_y2_selector.set(columns[3])
268
+
269
+ style_label = CTkLabel(self.containerFrame, text="Figure Style:")
270
+ style_label.grid(row=8, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
271
+
272
+ 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)
273
+ self.home_page.figure_style_selector.grid(row=9, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
274
+
275
+ elif (selected_graph == "Matrix Editor"):
276
+
277
+ folder = self.option_manager.get_project_folder()
278
+ if not os.path.exists(folder):
279
+ os.makedirs(folder)
280
+
281
+ # Get all CSV files in the folder and add their paths to a list
282
+ path_map = {}
283
+ name_list = []
284
+ for root, dirs, files in os.walk(folder):
285
+ for file in files:
286
+ if file.endswith(".csv"):
287
+ name = file.replace(".csv", "")
288
+ name_list.append(name)
289
+ path_map[name] = os.path.join(root, file)
290
+
291
+ if (len(name_list) == 0):
292
+ name_list.append("No files found...")
293
+ else:
294
+ if (self.option_manager.get("selected_csv").get() not in name_list):
295
+ self.option_manager.get("selected_csv").set(name_list[0])
296
+
297
+ file_label = CTkLabel(self.containerFrame, text="CSV File:")
298
+ file_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
299
+
300
+ 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)
301
+ self.home_page.csv_file_selector.grid(row=1, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
302
+
303
+ selected_file = self.option_manager.get("selected_csv").get()
304
+ if (selected_file in path_map and selected_file != self.home_page.open_file):
305
+ self.home_page.csv_data = pd.read_csv(path_map[selected_file])
306
+ print(self.home_page.csv_data)
307
+ self.home_page.open_file = selected_file
308
+
309
+ if (self.home_page.csv_data is not None):
310
+ # Get all column names of CSV
311
+ columns = self.home_page.csv_data.columns
312
+
313
+ style_label = CTkLabel(self.containerFrame, text="Figure Style:")
314
+ style_label.grid(row=2, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
315
+
316
+ 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)
317
+ self.home_page.figure_style_selector.grid(row=3, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
318
+
319
+ x_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
320
+ x_axis_label.grid(row=4, column=0, padx=(20, 20), pady=(40, 5), sticky="w")
321
+
322
+ self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_x"), command=self.home_page.update_graph)
323
+ self.home_page.csv_x_selector.grid(row=5, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
324
+
325
+ if (self.home_page.csv_x_selector.get() not in columns):
326
+ self.home_page.csv_x_selector.set(columns[1])
327
+
328
+ self.matrix_editor = me.MatrixEditor(self.containerFrame, width=280, option_manager=self.option_manager, home_page=self.home_page, columns=columns)
329
+ self.matrix_editor.grid(row=6, column=0, padx=(10, 10), pady=(10, 0), sticky="nsew")
330
+ self.matrix_editor.grid_columnconfigure(0, weight=1)
331
+ self.matrix_editor.grid_rowconfigure(0, weight=1)
332
+
333
+
334
+ #y1_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
335
+ #y1_axis_label.grid(row=6, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
336
+
337
+ #self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.option_manager.get("selected_y1"), command=self.home_page.update_graph)
338
+ #self.home_page.csv_y1_selector.grid(row=7, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
339
+
340
+ #if (self.home_page.csv_y1_selector.get() not in columns):
341
+ # self.home_page.csv_y1_selector.set(columns[2])
342
+ except Exception as e:
343
+ print(e)
344
+ pass
345
+
346
+ def load_special_csv(self, file_path):
347
+ file_metadata = {}
348
+ data_metadata = {}
349
+ mode = "file_metadata"
350
+ columns = []
351
+ data_lines = []
352
+
353
+ with open(file_path, "r") as file:
354
+ lines = file.readlines()
355
+
356
+ if (not lines[0].startswith("@")):
357
+ return {
358
+ "file_attributes": {},
359
+ "data_attributes": {},
360
+ "data": pd.read_csv(file_path)
361
+ }
362
+
363
+ for line in lines:
364
+ if (line.startswith("@H,")):
365
+ mode = "data_metadata"
366
+ columns = line.strip().rstrip(",").split(",")[1:]
367
+ continue
368
+ elif (line.startswith("@T,")):
369
+ mode = "file_metadata"
370
+ continue
371
+ elif (line.startswith(",") and mode == "data_metadata"):
372
+ mode = "file_data"
373
+
374
+ if (mode == "file_metadata"):
375
+ try:
376
+ key, value = line.strip().rstrip(",").split(",")
377
+ file_metadata[key] = value
378
+ except:
379
+ pass
380
+
381
+ elif (mode == "data_metadata"):
382
+ try:
383
+ values = line.strip().rstrip(",").split(",")
384
+ key = values[0]
385
+ values = values[1:]
386
+ if len(values) == len(columns):
387
+ data_metadata[key] = {}
388
+ for i in range(len(columns)):
389
+ data_metadata[key][columns[i]] = values[i]
390
+ except:
391
+ pass
392
+
393
+ elif (mode == "file_data"):
394
+ try:
395
+ values = line.strip().rstrip(",").split(",")[1:]
396
+ if len(values) == len(columns):
397
+ data_lines.append(values)
398
+ except:
399
+ pass
400
+
401
+ return {
402
+ "file_attributes": file_metadata,
403
+ "data_attributes": data_metadata,
404
+ "data": pd.DataFrame(data_lines, columns=columns)
405
+ }
@@ -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