Skip to content

Commit

Permalink
Avoid using .response_configuration within loops
Browse files Browse the repository at this point in the history
  • Loading branch information
yngve-sk committed Nov 28, 2024
1 parent 49dd7a7 commit c87502e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/ert/storage/local_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ def get_ensemble_state(self) -> List[Set[RealizationStorageState]]:
List of realization states.
"""

response_configs = self.experiment.response_configuration

def _parameters_exist_for_realization(realization: int) -> bool:
"""
Returns true if all parameters in the experiment have
Expand Down Expand Up @@ -478,7 +480,7 @@ def _responses_exist_for_realization(
True if responses exist for realization.
"""

if not self.experiment.response_configuration:
if not response_configs:
return True
path = self._realization_dir(realization)

Expand All @@ -493,16 +495,15 @@ def _has_response(_key: str) -> bool:
return _has_response(key)

is_expecting_any_responses = any(
bool(config.keys)
for config in self.experiment.response_configuration.values()
bool(config.keys) for config in response_configs.values()
)

if not is_expecting_any_responses:
return True

non_empty_response_configs = [
response
for response, config in self.experiment.response_configuration.items()
for response, config in response_configs.items()
if bool(config.keys)
]

Expand Down Expand Up @@ -896,10 +897,11 @@ def get_parameter_state(
def get_response_state(
self, realization: int
) -> Dict[str, RealizationStorageState]:
response_configs = self.experiment.response_configuration
path = self._realization_dir(realization)
return {
e: RealizationStorageState.RESPONSES_LOADED
if (path / f"{e}.parquet").exists()
else RealizationStorageState.UNDEFINED
for e in self.experiment.response_configuration
for e in response_configs
}

0 comments on commit c87502e

Please sign in to comment.