Skip to content

Commit

Permalink
Change the inputs of AreaPerMolecule to allow only 3 combinations of …
Browse files Browse the repository at this point in the history
…cell vectors
  • Loading branch information
MBartkowiakSTFC committed Mar 25, 2024
1 parent 4ac303e commit 515ca83
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 6 deletions.
15 changes: 10 additions & 5 deletions MDANSE/Src/MDANSE/Framework/Jobs/AreaPerMolecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ class AreaPerMolecule(IJob):
{"dependencies": {"trajectory": "trajectory"}},
)
settings["axis"] = (
"MultipleChoicesConfigurator",
"SingleChoiceConfigurator",
{
"label": "area vectors",
"choices": ["a", "b", "c"],
"nChoices": 2,
"default": ["a", "b"],
"choices": ["ab", "bc", "ac"],
"default": "ab",
},
)
settings["molecule_name"] = (
Expand All @@ -83,7 +82,13 @@ def initialize(self):
self.numberOfSteps = self.configuration["frames"]["number"]

# Extract the indexes corresponding to the axis selection (a=0,b=1,c=2).
self._axisIndexes = self.configuration["axis"]["indexes"]
axis_labels = self.configuration["axis"]["value"]
if axis_labels == "ab":
self._axisIndexes = [0, 1]
elif axis_labels == "bc":
self._axisIndexes = [1, 2]
else:
self._axisIndexes = [0, 2]

# The number of molecules that match the input name. Must be > 0.
self._nMolecules = len(
Expand Down
2 changes: 2 additions & 0 deletions MDANSE/Src/MDANSE/Framework/Jobs/OrderParameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class OrderParameter(IJob):
AOUN Bachir, PELLEGRINI Eric
"""

enabled = False

label = "Order parameter"

category = (
Expand Down
2 changes: 1 addition & 1 deletion MDANSE/Tests/UnitTests/Analysis/test_molecule_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def parameters():
parameters["r_values"] = (0.0, 10.0, 0.1)
parameters["per_axis"] = False
parameters["molecule_name"] = "InChI=1S/CO2/c2-1-3"
parameters["axis"] = ["a", "b"]
parameters["axis"] = "ab"
parameters["reference_direction"] = (0, 0, 1)
parameters["instrument_resolution"] = ("Gaussian", {"sigma": 1.0, "mu": 0.0})
parameters["interpolation_order"] = "3rd order"
Expand Down
70 changes: 70 additions & 0 deletions MDANSE_GUI/Src/MDANSE_GUI/InputWidgets/MultipleCombosWidget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# **************************************************************************
#
# MDANSE: Molecular Dynamics Analysis for Neutron Scattering Experiments
#
# @file Src/PyQtGUI/InputWidgets/SingleChoiceWidget.py
# @brief Implements module/class/test SingleChoiceWidget
#
# @homepage https://www.isis.stfc.ac.uk/Pages/MDANSEproject.aspx
# @license GNU General Public License v3 or higher (see LICENSE)
# @copyright Institut Laue Langevin 2013-now
# @copyright ISIS Neutron and Muon Source, STFC, UKRI 2021-now
# @authors Scientific Computing Group at ILL (see AUTHORS)
#
# **************************************************************************

from qtpy.QtWidgets import QComboBox
from qtpy.QtCore import Slot

from MDANSE_GUI.InputWidgets.WidgetBase import WidgetBase


class MultipleCombosWidget(WidgetBase):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
configurator = kwargs.get("configurator", None)
if configurator is None:
option_list = kwargs.get("choices", [])
number_of_boxes = 1
else:
option_list = configurator.choices
default_option = configurator.default
number_of_boxes = configurator.nChoices
self._fields = []
for field_number in range(number_of_boxes):
field = QComboBox(self._base)
field.addItems(option_list)
field.setCurrentText(default_option[field_number])
field.setEditable(False)
field.currentTextChanged.connect(self.updateValue)
if self._tooltip:
tooltip_text = self._tooltip
else:
tooltip_text = (
"A single option can be picked out of all the options listed."
)
field.setToolTip(tooltip_text)
self._layout.addWidget(field)
self._fields.append(field)
# self._field = field
self._configurator = configurator
self.default_labels()
self.update_labels()
self.updateValue()

def configure_using_default(self):
"""This is too complex to have a default value"""

def default_labels(self):
"""Each Widget should have a default tooltip and label,
which will be set in this method, unless specific
values are provided in the settings of the job that
is being configured."""
if self._label_text == "":
self._label_text = "ComboWidget"
if self._tooltip == "":
self._tooltip = "You only have one option. Choose wisely."

def get_widget_value(self):
result = [field.currentText() for field in self._fields]
return result
1 change: 1 addition & 0 deletions MDANSE_GUI/Src/MDANSE_GUI/Tabs/Visualisers/Action.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"XYZFileConfigurator": InputFileWidget,
"RunningModeConfigurator": RunningModeWidget,
"WeightsConfigurator": ComboWidget,
"MultipleChoicesConfigurator": MultipleCombosWidget,
"MoleculeSelectionConfigurator": MoleculeWidget,
"GroupingLevelConfigurator": ComboWidget,
"SingleChoiceConfigurator": ComboWidget,
Expand Down

0 comments on commit 515ca83

Please sign in to comment.