Skip to content

Commit

Permalink
Add merge with existing parameters function
Browse files Browse the repository at this point in the history
  • Loading branch information
xjules committed Oct 23, 2024
1 parent 762857e commit 199e335
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/ert/config/design_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@
from ert.config.gen_kw_config import GenKwConfig, TransformFunctionDefinition

from ._option_dict import option_dict
from .parsing import (
ConfigValidationError,
ErrorInfo,
)
from .parsing import ConfigValidationError, ErrorInfo

if TYPE_CHECKING:
from ert.config import (
ParameterConfig,
)
from ert.config import ParameterConfig

DESIGN_MATRIX_GROUP = "DESIGN_MATRIX"

Expand Down Expand Up @@ -74,6 +69,20 @@ def from_config_list(cls, config_list: List[str]) -> "DesignMatrix":
default_sheet=default_sheet,
)

def merge_with_existing_parameters(
self, existing_parameters: Dict[str, ParameterConfig]
) -> Dict[str, ParameterConfig]:
design_keys = self.parameter_configuration[DESIGN_MATRIX_GROUP].getKeyWords()
for parameter_group_name, genkw_group in existing_parameters.items():
existing_keys = genkw_group.getKeyWords()
if set(design_keys).issubset(set(existing_keys)):
self.parameter_configuration[parameter_group_name] = (
self.parameter_configuration[DESIGN_MATRIX_GROUP]
)
genkw_group.disabled = True
elif set(design_keys) & set(existing_keys):
raise ConfigValidationError("overlapping parameter names")

def read_design_matrix(
self,
) -> None:
Expand Down
1 change: 1 addition & 0 deletions src/ert/config/gen_kw_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class GenKwConfig(ParameterConfig):
output_file: Optional[str]
transform_function_definitions: List[TransformFunctionDefinition]
forward_init_file: Optional[str] = None
disabled: bool = False

def __post_init__(self) -> None:
self.transform_functions: List[TransformFunction] = []
Expand Down

0 comments on commit 199e335

Please sign in to comment.