Skip to content

Commit f6d1bee

Browse files
committed
Fixed bug in objective and constraint validation (optimization dialog)
1 parent 2c6ee44 commit f6d1bee

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pymead/gui/dialogs.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3142,6 +3142,7 @@ def objectives_changed(self, text: str):
31423142
widget = self.widget_dict["J"].widget
31433143
template = self.get_template()
31443144
self.gui_obj.objectives.clear()
3145+
any_constraint_failed = False
31453146
for obj_func_str in text.split(','):
31463147
objective = Objective(obj_func_str)
31473148
self.gui_obj.objectives.append(objective)
@@ -3150,25 +3151,28 @@ def objectives_changed(self, text: str):
31503151
return
31513152
try:
31523153
objective.update(template)
3153-
widget.setStyleSheet(f"QLineEdit {{background-color: {VALIDATION_SUCCESS}}}")
3154+
if not any_constraint_failed:
3155+
widget.setStyleSheet(f"QLineEdit {{background-color: {VALIDATION_SUCCESS}}}")
31543156
except FunctionCompileError:
31553157
widget.setStyleSheet(f"QLineEdit {{background-color: {VALIDATION_FAILURE}}}")
3156-
return
3158+
any_constraint_failed = True
31573159

31583160
def constraints_changed(self, text: str):
31593161
widget = self.widget_dict["G"].widget
31603162
template = self.get_template()
31613163
self.gui_obj.constraints.clear()
3164+
any_constraint_failed = False
31623165
for constraint_func_str in text.split(','):
31633166
if len(constraint_func_str) > 0:
31643167
constraint = Constraint(constraint_func_str)
31653168
self.gui_obj.constraints.append(constraint)
31663169
try:
31673170
constraint.update(template)
3168-
widget.setStyleSheet(f"QLineEdit {{background-color: {VALIDATION_SUCCESS}}}")
3171+
if not any_constraint_failed:
3172+
widget.setStyleSheet(f"QLineEdit {{background-color: {VALIDATION_SUCCESS}}}")
31693173
except FunctionCompileError:
31703174
widget.setStyleSheet(f"QLineEdit {{background-color: {VALIDATION_FAILURE}}}")
3171-
return
3175+
any_constraint_failed = True
31723176

31733177
def num_processors_changed(self, value: int):
31743178
widget = self.widget_dict["num_processors"].widget

0 commit comments

Comments
 (0)