Skip to content

Commit 01bf7d1

Browse files
committed
Fix GEN_KW update flag matching parameter name
The update flag was set using `"CONST" not in params`, which searches the entire list including the parameter name. A parameter named "CONST" with a non-CONST distribution would incorrectly get update=False. Narrow the check to only inspect the distribution type at params[1].
1 parent 15eafd5 commit 01bf7d1

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/ert/config/gen_kw_config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ def from_config_list(cls, config_list: GenKwConfigList) -> list[Self]:
194194
"to exclude this from updates, set UPDATE:FALSE.\n",
195195
gen_kw_key,
196196
)
197+
# "CONST" not in params and parsed.option.update
197198
try:
198199
return [
199200
cls(
@@ -203,7 +204,7 @@ def from_config_list(cls, config_list: GenKwConfigList) -> list[Self]:
203204
params[0], params[1], params[2:]
204205
),
205206
forward_init=False,
206-
update="CONST" not in params and parsed.options.update,
207+
update=params[1] != "CONST" and parsed.options.update,
207208
)
208209
for params in distributions_spec
209210
]

tests/ert/unit_tests/config/test_gen_kw_config.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,25 @@ def test_that_const_keyword_sets_update_to_false(tmpdir):
861861
assert gen_kw_config.update is False
862862

863863

864+
def test_that_parameter_named_const_with_non_const_distribution_is_updatable(tmp_path):
865+
"""Regression: update flag should only check the distribution type,
866+
not match "CONST" anywhere in the parameter definition.
867+
"""
868+
parameter_file = tmp_path / "parameter.txt"
869+
parameter_file.write_text("CONST NORMAL 0 1", encoding="utf-8")
870+
871+
configs = GenKwConfig.from_config_list(
872+
[
873+
"MY_KW",
874+
(str(parameter_file), parameter_file.read_text(encoding="utf-8")),
875+
{},
876+
]
877+
)
878+
assert len(configs) == 1
879+
assert configs[0].name == "CONST"
880+
assert configs[0].update is True
881+
882+
864883
def test_that_unexpected_positional_arg_count_raises_validation_error(tmp_path):
865884
parameter_file = tmp_path / "parameter.txt"
866885
parameter_file.write_text("KEY NORMAL 0 1", encoding="utf-8")

0 commit comments

Comments
 (0)