Skip to content

Commit

Permalink
Fixed bounds table equation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mlauer154 committed Sep 1, 2023
1 parent 32f7b30 commit ec626fc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
7 changes: 4 additions & 3 deletions pymead/gui/bounds_values_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 12 additions & 7 deletions pymead/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 = {
Expand Down
2 changes: 0 additions & 2 deletions pymead/optimization/opt_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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

0 comments on commit ec626fc

Please sign in to comment.