Skip to content

Commit

Permalink
Add step to localization kw to make gui work
Browse files Browse the repository at this point in the history
Deactivate correlation threshold if localization is off
Make it possible to deactivate localization from config
  • Loading branch information
dafeda committed Nov 24, 2022
1 parent c9e89d9 commit 12d10ac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ert/_c_wrappers/analysis/analysis_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ def get_mode_variables(mode: AnalysisMode) -> Dict[str, "VariableInfo"]:
"LOCALIZATION": {
"type": bool,
"value": DEFAULT_LOCALIZATION,
"labelname": "Switch for adaptive localization",
"labelname": "Adaptive localization",
},
"LOCALIZATION_CORRELATION_THRESHOLD": {
"type": float,
"min": 0.0,
"value": DEFAULT_LOCALIZATION_CORRELATION_THRESHOLD,
"max": 1.0,
"labelname": "Threshold defining high correlation",
"step": 0.1,
"labelname": "Adaptive localization correlation threshold",
},
}
ies_variables: Dict[str, "VariableInfo"] = {
Expand Down Expand Up @@ -198,6 +199,11 @@ def set_var(self, var_name: str, value: Union[float, int, bool, str]):
f"Variable {var_name} expected type {var['type']}"
f" received value `{value}` of type `{type(value)}`"
)
# When config is first read, `value` is a string that's either "False" or "True",
# but since bool("False") is True we need to convert it to bool.
if not isinstance(value, bool):
value = value.lower() != "false"

var["value"] = var["type"](value)
else:
raise KeyError(f"Variable {var_name} not found in module")
Expand Down
12 changes: 12 additions & 0 deletions src/ert/gui/ertwidgets/analysismodulevariablespanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ def __init__(self, analysis_module_name: str, facade: LibresFacade):
lambda value: self.update_truncation_spinners(value, truncation_spinner)
)

localization_checkbox = self.widget_from_layout(layout, "LOCALIZATION")
localization_correlation_spinner = self.widget_from_layout(
layout, "LOCALIZATION_CORRELATION_THRESHOLD"
)
localization_correlation_spinner.setEnabled(localization_checkbox.isChecked())
localization_checkbox.stateChanged.connect(
lambda localization_is_on: localization_correlation_spinner.setEnabled(True)
if localization_is_on
else localization_correlation_spinner.setEnabled(False)
)

self.setLayout(layout)
self.blockSignals(False)

Expand Down Expand Up @@ -166,6 +177,7 @@ def createSpinBox(
def createCheckBox(self, variable_name, variable_value, variable_type):
spinner = QCheckBox()
spinner.setChecked(variable_value)
spinner.setObjectName(variable_name)
spinner.clicked.connect(
partial(self.valueChanged, variable_name, variable_type, spinner)
)
Expand Down

0 comments on commit 12d10ac

Please sign in to comment.