From ec626fcb33bae0436b2ae7011ec2ced083346608 Mon Sep 17 00:00:00 2001 From: mlauer154 Date: Fri, 1 Sep 2023 15:31:52 -0500 Subject: [PATCH] Fixed bounds table equation bug --- pymead/gui/bounds_values_table.py | 7 ++++--- pymead/gui/gui.py | 19 ++++++++++++------- pymead/optimization/opt_setup.py | 2 -- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/pymead/gui/bounds_values_table.py b/pymead/gui/bounds_values_table.py index f2c85e1a..7b7ab0f4 100644 --- a/pymead/gui/bounds_values_table.py +++ b/pymead/gui/bounds_values_table.py @@ -82,15 +82,16 @@ def compare_data(self): for idx in indices_to_modify: if new_data[idx][0] == "" and new_data[idx - 1][0] not in params_to_modify: params_to_modify.append(new_data[idx - 1][0]) - elif new_data[idx + 1][0] == "" and new_data[idx + 1][0] not in params_to_modify: - params_to_modify.append(new_data[idx + 1][0]) else: params_to_modify.append(new_data[idx][0]) + if idx + 1 < len(new_data): + if new_data[idx + 1][0] == "" and new_data[idx + 1][0] not in params_to_modify: + params_to_modify.append(new_data[idx + 1][0]) for idx in indices_to_modify: nd = new_data[idx] data_to_modify[nd[0]] = {"value": nd[1], "bounds": [nd[2], nd[3]], "active": bool(nd[4]), "eq": nd[5]} - print(f"{data_to_modify = }") + # TODO: make equation cell later return data_to_modify diff --git a/pymead/gui/gui.py b/pymead/gui/gui.py index 64314c2b..34d83286 100644 --- a/pymead/gui/gui.py +++ b/pymead/gui/gui.py @@ -437,12 +437,19 @@ def edit_bounds(self): p.setReadonly(not data["active"][0]) else: p.setReadonly(not data["active"]) - if not p.hasChildren(): - self.param_tree_instance.add_equation_box(p, data["eq"]) - self.param_tree_instance.update_equation(p.child("Equation Definition"), data["eq"]) + if data["eq"] is not None: + if not p.hasChildren(): + self.param_tree_instance.add_equation_box(p, data["eq"]) + self.param_tree_instance.update_equation(p.child("Equation Definition"), data["eq"]) + else: + self.param_tree_instance.update_equation(p.child("Equation Definition"), data["eq"]) else: - self.param_tree_instance.update_equation(p.child("Equation Definition"), data["eq"]) - # TODO: fix bounds edit always attaching an equation even when string is empty + if not p.hasChildren(): + pass + else: + p.airfoil_param.remove_func() + p.setReadonly(False) + p.child("Equation Definition").remove() def auto_range_geometry(self): x_data_range, y_data_range = self.mea.get_curve_bounds() @@ -1555,8 +1562,6 @@ def shape_optimization(self, param_dict: dict, opt_settings: dict, mea: dict, pr np.savetxt(os.path.join(param_dict['opt_dir'], 'opt_X.dat'), res.X) # self.save_opt_plots(param_dict['opt_dir']) # not working at the moment - # TODO: font incorrect for optimization completed callback - def save_opt_plots(self, opt_dir: str): # Not working at the moment opt_plots = { diff --git a/pymead/optimization/opt_setup.py b/pymead/optimization/opt_setup.py index bf32877d..49f95058 100644 --- a/pymead/optimization/opt_setup.py +++ b/pymead/optimization/opt_setup.py @@ -218,7 +218,6 @@ def _evaluate(self, X, out, *args, **kwargs): class CustomDisplay(Display): - # TODO: this class needs work to be more general def __init__(self, **kwargs): super().__init__(**kwargs) self.term = MultiObjectiveSpaceToleranceTermination() @@ -283,4 +282,3 @@ def _do(self, problem, evaluator, algorithm): self.output.append(f"g{i + 1}_mean", g) self.set_progress_dict(self.output.attrs) - # TODO: push this into the main textarea