Skip to content

Commit

Permalink
enh: replace findText with findData of comboBox_visc_model (#169)
Browse files Browse the repository at this point in the history
Partial #167 

---------

Co-authored-by: NadiaSbaa
  • Loading branch information
RaghavaAlajangi authored Oct 2, 2024
1 parent 11ea2ec commit 828430a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
2.18.2
- enh: replace findText with findData of comboBox_visc_model
- fix: allow to select R binary when not found automatically
- enh: enable lut selection for emodulus computation in bulk actions (#71)
- enh: enable lut selection for emodulus computation (#71)
Expand Down
27 changes: 21 additions & 6 deletions shapeout2/gui/analysis/ana_slot.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(self, *args, **kwargs):
self._update_emodulus_medium_choices()
self._update_emodulus_temp_choices()
self._update_emodulus_lut_choices()
self._update_emodulus_visc_model_choices()

self.update_content()

Expand All @@ -63,7 +64,7 @@ def __getstate__(self):
else: # "other", user-defined medium
emod_visc = self.doubleSpinBox_visc.value() # user input
scenario = None
emod_visc_model = self.comboBox_visc_model.currentText()
emod_visc_model = self.comboBox_visc_model.currentData()
emod_select_lut = self.comboBox_lut.currentText()
state = {
"identifier": slot_state["identifier"],
Expand Down Expand Up @@ -139,11 +140,11 @@ def __setstate__(self, state):
self.comboBox_temp.blockSignals(True)
self.comboBox_temp.setCurrentIndex(idx_scen)
self.comboBox_temp.blockSignals(False)
idx_vm = self.comboBox_visc_model.findText(
emodulus.get("emodulus viscosity model", ""))
if idx_vm == -1:

idx_vm = self.comboBox_visc_model.findData(
# use defaults from previous session (Herold-2107)
idx_vm = 1
emodulus.get("emodulus viscosity model", "herold-2017"))

self.comboBox_visc_model.setCurrentIndex(idx_vm)
# Set current state of the emodulus lut
idx_lut = self.comboBox_lut.findData(emodulus.get("emodulus lut", ""))
Expand Down Expand Up @@ -284,6 +285,20 @@ def _update_emodulus_lut_choices(self):
self.comboBox_lut.setCurrentIndex(idx)
self.comboBox_lut.blockSignals(False)

def _update_emodulus_visc_model_choices(self):
"""update currently available viscosity model choices for YM
Signals are blocked.
"""
self.comboBox_visc_model.blockSignals(True)
self.comboBox_visc_model.clear()

choices = {"Herold (2017)": "herold-2017",
"Buyukurganci (2022)": "buyukurganci-2022"}
for name, data in choices.items():
self.comboBox_visc_model.addItem(name, data)
self.comboBox_visc_model.blockSignals(False)

@property
def current_slot_state(self):
if self.slot_ids:
Expand Down Expand Up @@ -369,7 +384,7 @@ def on_ui_changed(self):
medium = self.comboBox_medium.currentData()
tselec = self.comboBox_temp.currentData()
medium_key = ALIAS_MEDIA.get(medium, medium)
visc_model = self.comboBox_visc_model.currentText()
visc_model = self.comboBox_visc_model.currentData()
# Only show model selection if we are dealing with MC-PBS
self.comboBox_visc_model.setVisible(medium_key.count("MC-PBS"))
self.doubleSpinBox_visc.setStyleSheet("")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_gui_emodulus.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def test_changeable_lut_selection(qtbot):
assert wsl.comboBox_medium.currentData() == "CellCarrier"

# set viscosity model manually
idvm = wsl.comboBox_visc_model.findText("buyukurganci-2022")
idvm = wsl.comboBox_visc_model.findData("buyukurganci-2022")
wsl.comboBox_visc_model.setCurrentIndex(idvm)
# set lut manually
idlut = wsl.comboBox_lut.findData("HE-2D-FEM-22")
Expand Down Expand Up @@ -315,7 +315,7 @@ def test_changeable_lut_selection(qtbot):
).config["calculation"]["emodulus lut"] == "HE-3D-FEM-22"

# This is the actual test
assert wsl.comboBox_visc_model.currentText() == "buyukurganci-2022"
assert wsl.comboBox_visc_model.currentData() == "buyukurganci-2022"
assert wsl.comboBox_lut.currentText() == "HE-3D-FEM-22"

try:
Expand Down

0 comments on commit 828430a

Please sign in to comment.