Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action tab analysis loading performance update #354

Merged
merged 4 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MDANSE/Src/MDANSE/Framework/AtomSelector/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def get_idxs(self) -> set[int]:
if not switch:
continue

idxs = idxs | self._funcs[k](self.system, **args)
idxs.update(self._funcs[k](self.system, **args))

if self.settings["invert"]:
return self.all_idxs - idxs
Expand Down
23 changes: 13 additions & 10 deletions MDANSE_GUI/Src/MDANSE_GUI/InputWidgets/AtomSelectionWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# @authors Scientific Computing Group at ILL (see AUTHORS)
#
# **************************************************************************
from typing import Union
from typing import Union, Iterator
from itertools import count, groupby
from qtpy.QtCore import Qt, QEvent, Slot, QObject
from qtpy.QtGui import QStandardItem
Expand All @@ -26,7 +26,6 @@
QHBoxLayout,
QGroupBox,
QLabel,
QApplication,
QTextEdit,
)
from MDANSE.Framework.AtomSelector import Selector
Expand Down Expand Up @@ -111,12 +110,12 @@ def addItem(self, text: str) -> None:
"""
item = QStandardItem()
item.setText(text)
item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
item.setData(Qt.Unchecked, Qt.CheckStateRole)
item.setEnabled(True)
item.setCheckable(True)
self.model().appendRow(item)
self._items.append(item)

def getItems(self) -> QStandardItem:
def getItems(self) -> Iterator[QStandardItem]:
"""
Yields
------
Expand Down Expand Up @@ -240,7 +239,11 @@ def __init__(self, selector: Selector, field: QLineEdit, parent, *args, **kwargs
combo_layout = QHBoxLayout()
combo = CheckableComboBox()
items = [i for i in v.keys() if match_exists[k][i]]
# we blocksignals here as there can be some
# performance issues with a large number of items
combo.model().blockSignals(True)
combo.addItems(items)
combo.model().blockSignals(False)
combo.setObjectName(k)
combo.model().dataChanged.connect(self.update)
label = QLabel(self._cbox_text[k])
Expand Down Expand Up @@ -293,12 +296,12 @@ def update(self) -> None:
idxs = self.selector.get_idxs()
num_sel = len(idxs)

text = f"Number of atoms selected:\n{num_sel}\n\nSelected atoms:\n"
for at in self.selector.system.atom_list:
if at.index in idxs:
text += f"{at.index}) {at.full_name}\n"
text = [f"Number of atoms selected:\n{num_sel}\n\nSelected atoms:\n"]
atoms = self.selector.system.atom_list
for idx in idxs:
text.append(f"{idx}) {atoms[idx].full_name}\n")

self.right.setText(text)
self.right.setText("".join(text))

def apply(self) -> None:
"""Set the field of the AtomSelectionWidget to the currently
Expand Down
14 changes: 4 additions & 10 deletions MDANSE_GUI/Src/MDANSE_GUI/InputWidgets/HDFTrajectoryWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# MDANSE: Molecular Dynamics Analysis for Neutron Scattering Experiments
#
# @file Src/PyQtGUI/InputWidgets/HDFTrajectoryWidget.py
# @file MDANSE_GUI/InputWidgets/HDFTrajectoryWidget.py
# @brief Implements module/class/test HDFTrajectoryWidget
#
# @homepage https://www.isis.stfc.ac.uk/Pages/MDANSEproject.aspx
Expand All @@ -12,18 +12,15 @@
# @authors Scientific Computing Group at ILL (see AUTHORS)
#
# **************************************************************************

import os

from qtpy.QtWidgets import QLineEdit, QSpinBox, QLabel
from qtpy.QtCore import Slot, Signal
from qtpy.QtGui import QIntValidator
from qtpy.QtWidgets import QLabel

from MDANSE.Framework.InputData.HDFTrajectoryInputData import HDFTrajectoryInputData
from MDANSE_GUI.InputWidgets.WidgetBase import WidgetBase


class HDFTrajectoryWidget(WidgetBase):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
source_object = kwargs.get("source_object", None)
Expand All @@ -32,19 +29,16 @@ def __init__(self, *args, **kwargs):
except AttributeError:
filename = None
if filename is not None:
trajectory = HDFTrajectoryInputData(filename)
self._configurator.configure(filename)
label = QLabel(filename, self._base)
self._layout.addWidget(label)
self._configurator.configure(filename)
trajectory_path, _ = os.path.split(filename)
self.default_path = trajectory_path
else:
label = QLabel("No Trajectory available", self._base)
self._layout.addWidget(label)
self._trajectory = trajectory
self.default_labels()
self.update_labels()
self.updateValue()
if self._tooltip:
tooltip_text = self._tooltip
else:
Expand Down
1 change: 0 additions & 1 deletion MDANSE_GUI/Src/MDANSE_GUI/Tabs/Visualisers/Action.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ def update_panel(self, job_name: str) -> None:
dtype = value[0]
ddict = value[1]
configurator = job_instance.configuration[key]
configurator.configure(self._input_trajectory)
if not "label" in ddict.keys():
ddict["label"] = key
ddict["configurator"] = configurator
Expand Down
Loading