Skip to content

Commit

Permalink
Allow empty active realizations
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Apr 30, 2024
1 parent 973f5c4 commit 4d16ba1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/ert/gui/ertwidgets/models/activerealizationsmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@


class ActiveRealizationsModel(ValueModel):
def __init__(self, ensemble_size: int):
def __init__(self, ensemble_size: int, show_default: bool = True):
self.show_default = show_default
self.ensemble_size = ensemble_size
ValueModel.__init__(self, self.getDefaultValue())
self._custom = False
Expand All @@ -22,8 +23,10 @@ def setValueFromMask(self, mask):
self.setValue(mask_to_rangestring(mask))

def getDefaultValue(self):
size = self.ensemble_size
return f"0-{size-1:d}"
if self.show_default:
size = self.ensemble_size
return f"0-{size-1:d}"
return None

def getActiveRealizationsMask(self) -> List[bool]:
return ActiveRange(rangestring=self.getValue(), length=self.ensemble_size).mask
3 changes: 2 additions & 1 deletion src/ert/gui/simulation/evaluate_ensemble_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, ensemble_size: int, run_path: str, notifier: ErtNotifier):
layout.addRow(QLabel("Number of realizations:"), number_of_realizations_label)

self._active_realizations_field = StringBox(
ActiveRealizationsModel(ensemble_size),
ActiveRealizationsModel(ensemble_size, show_default=False),
"config/simulation/active_realizations",
)
self._active_realizations_field.setValidator(
Expand All @@ -66,6 +66,7 @@ def isConfigurationValid(self) -> bool:
return (
self._active_realizations_field.isValid()
and self._ensemble_selector.currentIndex() != -1
and bool(self._active_realizations_field.text())
)

def getSimulationArguments(self) -> Arguments:
Expand Down

0 comments on commit 4d16ba1

Please sign in to comment.