Skip to content

Commit

Permalink
Rename states to observables
Browse files Browse the repository at this point in the history
  • Loading branch information
zhe-slac committed Mar 18, 2024
1 parent e104edb commit 9caea71
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
12 changes: 6 additions & 6 deletions src/badger/gui/default/components/env_cbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ def init_ui(self):
btn_add_sta.setDisabled(True)
hbox_action_sta.addWidget(btn_add_sta)
hbox_action_sta.addStretch()
self.list_sta = QListWidget()
self.list_sta.setMaximumHeight(80)
# self.list_sta.setFixedHeight(64)
self.list_sta.setViewportMargins(2, 2, 17, 2)
vbox_sta_edit.addWidget(self.list_sta)
self.list_obs = QListWidget()
self.list_obs.setMaximumHeight(80)
# self.list_obs.setFixedHeight(64)
self.list_obs.setViewportMargins(2, 2, 17, 2)
vbox_sta_edit.addWidget(self.list_obs)
# vbox_sta_edit.addStretch()
hbox_sta.addWidget(edit_sta_col)
cbox_more.setContentLayout(vbox_more)
Expand Down Expand Up @@ -305,4 +305,4 @@ def fit_content(self):
return
self._fit_content(self.list_obj)
self._fit_content(self.list_con)
self._fit_content(self.list_sta)
self._fit_content(self.list_obs)
30 changes: 15 additions & 15 deletions src/badger/gui/default/components/routine_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ def refresh_ui(self, routine: Routine = None):

self.generators = list_generators()
self.envs = list_env()
# Clean up the constraints/states list
# Clean up the constraints/observables list
self.env_box.list_con.clear()
self.env_box.list_sta.clear()
self.env_box.list_obs.clear()

if routine is None:
# Reset the generator and env configs
Expand Down Expand Up @@ -370,7 +370,7 @@ def select_env(self, i):
self.env_box.obj_table.update_objectives(objs_env)

self.env_box.list_con.clear()
self.env_box.list_sta.clear()
self.env_box.list_obs.clear()
self.env_box.fit_content()
# self.routine = None

Expand Down Expand Up @@ -520,13 +520,13 @@ def add_state(self, name=None):

var_names = [next(iter(d)) for d in self.configs['variables']]
options = self.configs['observations'] + var_names
item = QListWidgetItem(self.env_box.list_sta)
item = QListWidgetItem(self.env_box.list_obs)
sta_item = state_item(options,
lambda: self.env_box.list_sta.takeItem(
self.env_box.list_sta.row(item)), name)
lambda: self.env_box.list_obs.takeItem(
self.env_box.list_obs.row(item)), name)
item.setSizeHint(sta_item.sizeHint())
self.env_box.list_sta.addItem(item)
self.env_box.list_sta.setItemWidget(item, sta_item)
self.env_box.list_obs.addItem(item)
self.env_box.list_obs.setItemWidget(item, sta_item)
self.env_box.fit_content()

def _compose_vocs(self) -> (VOCS, List[str]):
Expand All @@ -547,19 +547,19 @@ def _compose_vocs(self) -> (VOCS, List[str]):
if critical:
critical_constraints.append(con_name)

states = []
for i in range(self.env_box.list_sta.count()):
item = self.env_box.list_sta.item(i)
item_widget = self.env_box.list_sta.itemWidget(item)
sta_name = item_widget.cb_sta.currentText()
states.append(sta_name)
observables = []
for i in range(self.env_box.list_obs.count()):
item = self.env_box.list_obs.item(i)
item_widget = self.env_box.list_obs.itemWidget(item)
obs_name = item_widget.cb_sta.currentText()
observables.append(obs_name)

vocs = VOCS(
variables=variables,
objectives=objectives,
constraints=constraints,
constants={},
observables=states,
observables=observables,
)

return vocs, critical_constraints
Expand Down
32 changes: 16 additions & 16 deletions src/badger/gui/default/components/run_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ def init_plots(self, routine: Routine = None, run_filename: str = None):

# if statics exist delete that plot
try:
self.monitor.removeItem(self.plot_sta)
self.plot_sta.removeItem(self.inspector_state)
del self.plot_sta
self.monitor.removeItem(self.plot_obs)
self.plot_obs.removeItem(self.inspector_state)
del self.plot_obs
except:
pass

Expand Down Expand Up @@ -480,22 +480,22 @@ def init_plots(self, routine: Routine = None, run_filename: str = None):
# Configure state plots
if sta_names:
try:
self.plot_sta
self.plot_obs
except:
self.plot_sta = plot_sta = add_axes(
self.monitor, "states", 'Evaluation History (S)',
self.plot_obs = plot_obs = add_axes(
self.monitor, "observables", 'Evaluation History (S)',
self.inspector_state, row=2, col=0
)
plot_sta.setXLink(self.plot_obj)
plot_obs.setXLink(self.plot_obj)

self.curves_sta = self._configure_plot(
self.plot_sta, self.inspector_state, sta_names
self.plot_obs, self.inspector_state, sta_names
)
else:
try:
self.monitor.removeItem(self.plot_sta)
self.plot_sta.removeItem(self.inspector_state)
del self.plot_sta
self.monitor.removeItem(self.plot_obs)
self.plot_obs.removeItem(self.inspector_state)
del self.plot_obs
except:
pass

Expand Down Expand Up @@ -598,7 +598,7 @@ def enable_auto_range(self):
self.plot_con.enableAutoRange()

if self.vocs.observable_names:
self.plot_sta.enableAutoRange()
self.plot_obs.enableAutoRange()

def open_extensions_palette(self):
self.extensions_palette.show()
Expand Down Expand Up @@ -960,14 +960,14 @@ def select_x_axis(self, i):
if self.vocs.constraint_names:
self.plot_con.setLabel('bottom', 'time (s)')
if self.vocs.observable_names:
self.plot_sta.setLabel('bottom', 'time (s)')
self.plot_obs.setLabel('bottom', 'time (s)')
else:
self.plot_var.setLabel('bottom', 'iterations')
self.plot_obj.setLabel('bottom', 'iterations')
if self.vocs.constraint_names:
self.plot_con.setLabel('bottom', 'iterations')
if self.vocs.observable_names:
self.plot_sta.setLabel('bottom', 'iterations')
self.plot_obs.setLabel('bottom', 'iterations')

# Update inspector line position
if i:
Expand Down Expand Up @@ -999,15 +999,15 @@ def on_mouse_click(self, event):
if self.vocs and self.vocs.constraint_names:
coor_con = self.plot_con.vb.mapSceneToView(event._scenePos)
if self.vocs and self.vocs.observable_names:
coor_sta = self.plot_sta.vb.mapSceneToView(event._scenePos)
coor_sta = self.plot_obs.vb.mapSceneToView(event._scenePos)
coor_var = self.plot_var.vb.mapSceneToView(event._scenePos)

flag = self.plot_obj.viewRect().contains(coor_obj) or \
self.plot_var.viewRect().contains(coor_var)
if self.vocs and self.vocs.constraint_names:
flag = flag or self.plot_con.viewRect().contains(coor_con)
if self.vocs and self.vocs.observable_names:
flag = flag or self.plot_sta.viewRect().contains(coor_sta)
flag = flag or self.plot_obs.viewRect().contains(coor_sta)

if flag:
self.sync_ins(coor_obj.x())
Expand Down

0 comments on commit 9caea71

Please sign in to comment.