Skip to content

Commit

Permalink
refactor the result panel
Browse files Browse the repository at this point in the history
  • Loading branch information
superstar54 committed Oct 27, 2023
1 parent 59353d2 commit 0a27bee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
19 changes: 4 additions & 15 deletions src/aiidalab_qe/plugins/electronic_structure/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,27 +216,16 @@ def __init__(self, node=None, **kwargs):
super().__init__(node=node, **kwargs)

def _observe_group_dos_by(self, change):
data = export_data(self.node, group_dos_by=change["new"])
bands_data = data.get("bands", None)
dos_data = data.get("dos", None)
_bands_plot_view = BandsPlotWidget(
bands=bands_data,
dos=dos_data,
)
self.children = [
self.settings,
_bands_plot_view,
]
"""Update the view of the widget when the group_dos_by value changes."""
self._update_view()

def _update_view(self):
"""Update the view of the widget."""
#
data = export_data(self.node, group_dos_by=self.group_dos_by.value)
bands_data = data.get("bands", None)
dos_data = data.get("dos", None)
_bands_plot_view = BandsPlotWidget(
bands=bands_data,
dos=dos_data,
bands=data.get("bands", None),
dos=data.get("dos", None),
)
# update the electronic structure tab
self.children = [
Expand Down
10 changes: 6 additions & 4 deletions tests/test_plugins_electronic_structure.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def test_electronic_structure(generate_qeapp_workchain):
"""test the report can be properly generated from the builder without errors"""
"""Test the electronic structure tab."""
from aiida import engine

from aiidalab_qe.app.result.workchain_viewer import WorkChainViewer
Expand All @@ -9,10 +9,12 @@ def test_electronic_structure(generate_qeapp_workchain):
wkchain.node.set_process_state(engine.ProcessState.FINISHED)
wcv = WorkChainViewer(wkchain.node)
# find the tab with the identifier "electronic_structure"
# the built-in summary and structure tabs is not a plugin panel,
# thus don't have identifiers
tab = [
tab
for tab in wcv.result_tabs.children
if tab.identifier == "electronic_structure"
if getattr(tab, "identifier", "") == "electronic_structure"
][0]
# check the content of the tab
assert "DOS grouped by:" == tab.children[0].children[0].value
# It should have two children: settings and the _bands_plot_view
assert len(tab.children) == 2

0 comments on commit 0a27bee

Please sign in to comment.