Skip to content

Commit

Permalink
Only set active realizations from selected ensemble when restart is c…
Browse files Browse the repository at this point in the history
…hecked es_mda
  • Loading branch information
larsevj authored and HakonSohoel committed Dec 10, 2024
1 parent e134e15 commit 96836d9
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/ert/gui/simulation/multiple_data_assimilation_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ def __init__(
self._active_realizations_model, # type: ignore
"config/simulation/active_realizations",
)
self._active_realizations_field.setObjectName("active_realizations_box")
self._active_realizations_field.setValidator(RangeStringArgument(ensemble_size))
self._ensemble_selector = EnsembleSelector(notifier)
self._realizations_from_fs()
layout.addRow("Active realizations:", self._active_realizations_field)

self._restart_box = QCheckBox("")
Expand All @@ -114,6 +114,7 @@ def __init__(
self._restart_box.toggled.connect(self.update_experiment_edit)

self._restart_box.setEnabled(bool(self._ensemble_selector._ensemble_list()))
self._ensemble_selector.setEnabled(False)
layout.addRow("Restart run:", self._restart_box)

self._ensemble_selector.ensemble_populated.connect(self.restart_run_toggled)
Expand Down Expand Up @@ -189,6 +190,11 @@ def restart_run_toggled(self) -> None:
if self._restart_box.isChecked()
else MultipleDataAssimilation.default_weights
)
if self._restart_box.isChecked():
self._realizations_from_fs()
else:
# If box is unchecked we reset to the default mask
self._active_realizations_field.model.setValue(value="")

def _createInputForWeights(self, layout: QFormLayout) -> None:
relative_iteration_weights_model = ValueModel(self.weights)
Expand Down
40 changes: 39 additions & 1 deletion tests/ert/ui_tests/gui/test_restart_esmda.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from ert.gui.ertwidgets import StringBox
from ert.gui.simulation.experiment_panel import ExperimentPanel
from ert.gui.simulation.run_dialog import RunDialog
from ert.run_models import MultipleDataAssimilation
from ert.run_models import MultipleDataAssimilation, SingleTestRun

from .conftest import get_child

Expand Down Expand Up @@ -40,6 +40,44 @@ def test_restart_esmda(ensemble_experiment_has_run_no_failure, qtbot):
)


def test_active_realizations_esmda(opened_main_window_poly, qtbot):
"""This runs a single test run and then verifies that this does
not interfere with the activate realizations in the es_mda panel
unless the restart from that specific ensemble is checked.
"""
gui = opened_main_window_poly

experiment_panel = get_child(gui, ExperimentPanel)
simulation_mode_combo = get_child(experiment_panel, QComboBox)
simulation_mode_combo.setCurrentText(SingleTestRun.name())

single_test_run_panel = gui.findChild(QWidget, name="Single_test_run_panel")
assert single_test_run_panel
run_experiment = experiment_panel.findChild(QWidget, name="run_experiment")
qtbot.mouseClick(run_experiment, Qt.MouseButton.LeftButton)
qtbot.waitUntil(lambda: gui.findChild(RunDialog) is not None)
run_dialog = gui.findChild(RunDialog)
qtbot.waitUntil(lambda: run_dialog.is_simulation_done() == True, timeout=15000)
assert (
run_dialog._total_progress_label.text()
== "Total progress 100% — Experiment completed."
)

simulation_mode_combo.setCurrentText(MultipleDataAssimilation.name())
es_mda_panel = gui.findChild(QWidget, name="ES_MDA_panel")
assert es_mda_panel
active_reals = gui.findChild(StringBox, "active_realizations_box")
assert active_reals.text() == "0-19"

restart_checkbox = es_mda_panel.findChild(QCheckBox, name="restart_checkbox_esmda")
assert restart_checkbox
assert not restart_checkbox.isChecked()
restart_checkbox.click()
assert active_reals.text() == "0"
restart_checkbox.click()
assert active_reals.text() == "0-19"


def test_custom_weights_stored_and_retrieved_from_metadata_esmda(
opened_main_window_minimal_realizations, qtbot
):
Expand Down

0 comments on commit 96836d9

Please sign in to comment.