Skip to content

Commit

Permalink
Delete duplicate enum
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Jan 6, 2025
1 parent 34a75ca commit 790933d
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/ert/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from .analysis_module import AnalysisModule, ESSettings, IESSettings
from .capture_validation import capture_validation
from .design_matrix import DesignMatrix
from .enkf_observation_implementation_type import ObservationType
from .ensemble_config import EnsembleConfig
from .ert_config import ErtConfig
from .ert_plugin import CancelPluginException, ErtPlugin
Expand Down Expand Up @@ -33,6 +32,7 @@
QueueSystem,
WarningInfo,
)
from .parsing.observations_parser import ObservationType
from .queue_config import QueueConfig
from .response_config import InvalidResponseFile, ResponseConfig
from .summary_config import SummaryConfig
Expand Down
6 changes: 0 additions & 6 deletions src/ert/config/enkf_observation_implementation_type.py

This file was deleted.

6 changes: 3 additions & 3 deletions src/ert/config/observation_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import numpy as np

from .enkf_observation_implementation_type import ObservationType
from .general_observation import GenObservation
from .parsing import ObservationType
from .summary_observation import SummaryObservation

if TYPE_CHECKING:
Expand All @@ -31,7 +31,7 @@ def __len__(self) -> int:
return len(self.observations)

def to_dataset(self, active_list: list[int]) -> polars.DataFrame:
if self.observation_type == ObservationType.GEN_OBS:
if self.observation_type == ObservationType.GENERAL:
dataframes = []
for time_step, node in self.observations.items():
if active_list and time_step not in active_list:
Expand All @@ -58,7 +58,7 @@ def to_dataset(self, active_list: list[int]) -> polars.DataFrame:

combined = polars.concat(dataframes)
return combined
elif self.observation_type == ObservationType.SUMMARY_OBS:
elif self.observation_type == ObservationType.SUMMARY:
observations = []
actual_response_key = self.observation_key
actual_observation_keys = []
Expand Down
13 changes: 6 additions & 7 deletions src/ert/config/observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@

from ert.validation import rangestring_to_list

from .enkf_observation_implementation_type import ObservationType
from .gen_data_config import GenDataConfig
from .general_observation import GenObservation
from .observation_vector import ObsVector
from .parsing import ConfigWarning, HistorySource
from .parsing import ConfigWarning, HistorySource, ObservationType
from .parsing.observations_parser import (
DateValues,
ErrorValues,
Expand Down Expand Up @@ -46,13 +45,13 @@ class EnkfObs:
def __post_init__(self) -> None:
grouped: dict[str, list[polars.DataFrame]] = {}
for vec in self.obs_vectors.values():
if vec.observation_type == ObservationType.SUMMARY_OBS:
if vec.observation_type == ObservationType.SUMMARY:
if "summary" not in grouped:
grouped["summary"] = []

grouped["summary"].append(vec.to_dataset([]))

elif vec.observation_type == ObservationType.GEN_OBS:
elif vec.observation_type == ObservationType.GENERAL:
if "gen_data" not in grouped:
grouped["gen_data"] = []

Expand Down Expand Up @@ -183,7 +182,7 @@ def _handle_history_observation(

return {
summary_key: ObsVector(
ObservationType.SUMMARY_OBS,
ObservationType.SUMMARY,
summary_key,
"summary",
data,
Expand Down Expand Up @@ -334,7 +333,7 @@ def _handle_summary_observation(
)
return {
obs_key: ObsVector(
ObservationType.SUMMARY_OBS,
ObservationType.SUMMARY,
summary_key,
"summary",
{date: SummaryObservation(summary_key, obs_key, value, std_dev)},
Expand Down Expand Up @@ -463,7 +462,7 @@ def _handle_general_observation(
try:
return {
obs_key: ObsVector(
ObservationType.GEN_OBS,
ObservationType.GENERAL,
obs_key,
response_key,
{
Expand Down
2 changes: 2 additions & 0 deletions src/ert/config/parsing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .history_source import HistorySource
from .hook_runtime import HookRuntime
from .lark_parser import parse, parse_contents, read_file
from .observations_parser import ObservationType
from .queue_system import QueueSystem, QueueSystemWithGeneric
from .schema_item_type import SchemaItemType
from .types import MaybeWithContext
Expand All @@ -31,6 +32,7 @@
"HistorySource",
"HookRuntime",
"MaybeWithContext",
"ObservationType",
"QueueSystem",
"QueueSystemWithGeneric",
"SchemaItemType",
Expand Down
2 changes: 1 addition & 1 deletion src/ert/libres_facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def get_observations(self) -> EnkfObs:

def get_data_key_for_obs_key(self, observation_key: str) -> str:
obs = self.config.enkf_obs[observation_key]
if obs.observation_type == ObservationType.SUMMARY_OBS:
if obs.observation_type == ObservationType.SUMMARY:
return next(iter(obs.observations.values())).summary_key # type: ignore
else:
return obs.data_key
Expand Down
2 changes: 1 addition & 1 deletion tests/ert/unit_tests/config/test_observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_observations(minimum_case):
summary_key = "test_key"
observation_key = "test_obs_key"
observation_vector = ObsVector(
ObservationType.SUMMARY_OBS,
ObservationType.SUMMARY,
observation_key,
"summary",
{},
Expand Down
6 changes: 2 additions & 4 deletions tests/ert/unit_tests/storage/test_local_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@
Field,
GenDataConfig,
GenKwConfig,
ObservationType,
ParameterConfig,
ResponseConfig,
SummaryConfig,
SurfaceConfig,
)
from ert.config.enkf_observation_implementation_type import (
ObservationType,
)
from ert.config.gen_kw_config import TransformFunctionDefinition
from ert.config.general_observation import GenObservation
from ert.config.observation_vector import ObsVector
Expand Down Expand Up @@ -537,7 +535,7 @@ def _inner(params):
words,
st.builds(
ObsVector,
observation_type=st.just(ObservationType.GEN_OBS),
observation_type=st.just(ObservationType.GENERAL),
observation_key=words,
data_key=words,
observations=st.dictionaries(
Expand Down

0 comments on commit 790933d

Please sign in to comment.