Skip to content

Commit

Permalink
Clean up bands pdos widget
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Nov 14, 2024
1 parent c66af47 commit f16abc2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 32 deletions.
17 changes: 0 additions & 17 deletions src/aiidalab_qe/common/bands_pdos/bandpdoswidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,6 @@ def render(self):
layout=ipw.Layout(display="none"),
)

# self.plot_button = ipw.Button(
# description="Plot",
# icon="line-chart",
# button_style="success",
# )
# ipw.dlink(
# (self._model, "ready"),
# (self.plot_button, "disabled"),
# lambda ready: not ready,
# )
# self.plot_button.on_click(self._update_plot)

self.pdos_options = ipw.VBox(
children=[
ipw.HTML("""
Expand Down Expand Up @@ -218,11 +206,6 @@ def render(self):
"""),
self.pdos_options,
self.download_button,
# ipw.HBox(
# children=[
# self.plot_button,
# ],
# ),
self.legend_interaction_description,
self.bands_widget,
]
Expand Down
30 changes: 15 additions & 15 deletions src/aiidalab_qe/common/bands_pdos/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,35 +45,23 @@ class BandsPdosModel(Model):
needs_pdos_options = tl.Bool(False)
needs_projections_controls = tl.Bool(False)

ready = tl.Bool(False)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

ipw.dlink(
(self, "bands"),
(self, "needs_projections_controls"),
lambda node: node is not None and "projwfc" in node,
lambda _: self._has_bands_projections,
)
ipw.dlink(
(self, "pdos"),
(self, "needs_pdos_options"),
lambda _: self.pdos is not None or self.needs_projections_controls,
lambda _: self._has_pdos or self.needs_projections_controls,
)
ipw.dlink(
(self, "needs_projections_controls"),
(self, "needs_pdos_options"),
lambda _: self.pdos is not None or self.needs_projections_controls,
)
ipw.dlink(
(self, "bands"),
(self, "ready"),
lambda node: bool(node),
)
ipw.dlink(
(self, "pdos"),
(self, "ready"),
lambda node: bool(node),
lambda _: self._has_pdos or self.needs_projections_controls,
)

def fetch_data(self):
Expand All @@ -83,6 +71,18 @@ def fetch_data(self):
if self.pdos:
self.pdos_data = self._get_pdos_data()

@property
def _has_bands(self):
return bool(self.bands)

@property
def _has_pdos(self):
return bool(self.pdos)

@property
def _has_bands_projections(self):
return self._has_bands and "projwfc" in self.bands

def _get_pdos_data(self):
if not self.pdos:
return None
Expand Down

0 comments on commit f16abc2

Please sign in to comment.