Skip to content

Commit

Permalink
(miniwip) refactor it
Browse files Browse the repository at this point in the history
  • Loading branch information
Yngve S. Kristiansen committed Jun 20, 2024
1 parent 898c18d commit cf2efc0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/ert/storage/local_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def create_realization_dir(realization: int) -> Path:
self._realization_dir = create_realization_dir
self._realization_states = _MultiRealizationStateDict()

def on_experiment_initialized(self):
def on_experiment_initialized(self) -> None:
"""
Executes logic that depends on the experiment of the ensemble to exist.
For example, if some logic needs to traverse response/parameter configs,
Expand Down
13 changes: 8 additions & 5 deletions src/ert/storage/realization_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def assign_state(self, src_state: "_SingleRealizationStateDictEntry") -> Self:


class _SingleRealizationStateDict:
def __init__(self):
def __init__(self) -> None:
self._items_by_kind: Dict[str, Dict[str, _SingleRealizationStateDictEntry]] = {}

def _set_item(

Check failure on line 46 in src/ert/storage/realization_state.py

View workflow job for this annotation

GitHub Actions / type-checking (3.12)

Function is missing a return type annotation
Expand Down Expand Up @@ -147,7 +147,10 @@ def get_parameter(self, key_or_group: str) -> _SingleRealizationStateDictEntry:
)

kind_dict = self._lookup_single_kind_dict_for_key(key_or_group)
return kind_dict.get(key_or_group)

entry = kind_dict.get(key_or_group)
assert entry is not None
return entry

def copy(self) -> "_SingleRealizationStateDict":
cpy = _SingleRealizationStateDict()
Expand Down Expand Up @@ -229,16 +232,16 @@ def to_tuples(self) -> List[Tuple[str, str, _SingleRealizationStateDictEntry]]:


class _MultiRealizationStateDict:
def __init__(self):
def __init__(self) -> None:
self._items: Dict[int, _SingleRealizationStateDict] = {}

def has_response(self, realization: int, key: str):
def has_response(self, realization: int, key: str) -> bool:
if realization not in self._items:
return False

return self._items[realization].has_response_key_or_group(key)

def has_parameter_group(self, realization: int, key: str):
def has_parameter_group(self, realization: int, key: str) -> bool:
if realization not in self._items:
return False

Expand Down

0 comments on commit cf2efc0

Please sign in to comment.