Skip to content

Commit

Permalink
Make show_dm_parameters not visible when DESIGN_MATRIX is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
xjules committed Oct 11, 2024
1 parent 90e5e34 commit 07aaf7c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
18 changes: 8 additions & 10 deletions src/ert/gui/simulation/ensemble_experiment_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,19 @@ def __init__(
layout.addRow("Active realizations", self._active_realizations_field)

design_matrix = analysis_config.design_matrix
show_dm_param_button = QPushButton("Show parameters")
show_dm_param_button.setObjectName("show-dm-parameters")
show_dm_param_button.setMinimumWidth(50)
if design_matrix is not None:
show_dm_param_button = QPushButton("Show parameters")
show_dm_param_button.setObjectName("show-dm-parameters")
show_dm_param_button.setMinimumWidth(50)

button_layout = QHBoxLayout()
button_layout.addWidget(show_dm_param_button)
button_layout.addStretch() # Add stretch to push the button to the left
button_layout = QHBoxLayout()
button_layout.addWidget(show_dm_param_button)
button_layout.addStretch() # Add stretch to push the button to the left

layout.addRow("Design Matrix", button_layout)
if design_matrix is not None:
layout.addRow("Design Matrix", button_layout)
show_dm_param_button.clicked.connect(
lambda: self.on_show_dm_params_clicked(design_matrix)
)
else:
show_dm_param_button.setDisabled(True)

self.setLayout(layout)

Expand Down
17 changes: 5 additions & 12 deletions tests/ert/unit_tests/gui/simulation/test_run_dialog.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import os
from pathlib import Path
from queue import SimpleQueue
from unittest.mock import MagicMock, Mock, patch

import pandas as pd
import pytest
from pytestqt.qtbot import QtBot
from qtpy import QtWidgets
Expand All @@ -18,7 +16,7 @@
)

import ert
from ert.config import DesignMatrix, ErtConfig
from ert.config import ErtConfig
from ert.ensemble_evaluator import state
from ert.ensemble_evaluator.event import (
EndEvent,
Expand Down Expand Up @@ -751,12 +749,7 @@ def test_that_design_matrix_show_parameters_button(
show_dm_parameters = simulation_settings.findChild(
QPushButton, "show-dm-parameters"
)

assert isinstance(show_dm_parameters, QPushButton)
assert show_dm_parameters.isEnabled() == design_matrix_entry
if show_dm_parameters.isEnabled():
design_matrix_df = pd.DataFrame({"a": [1, 2, 3], "b": [3, 4, 5]})
with patch.object(
DesignMatrix, "design_matrix_df", design_matrix_df
), patch.object(DesignMatrix, "xls_filename", Path(xls_filename)):
qtbot.mouseClick(show_dm_parameters, Qt.LeftButton)
if design_matrix_entry:
assert isinstance(show_dm_parameters, QPushButton)
else:
assert show_dm_parameters is None

0 comments on commit 07aaf7c

Please sign in to comment.