diff --git a/src/ert/dark_storage/common.py b/src/ert/dark_storage/common.py index 629f6d46c81..0508a5b6284 100644 --- a/src/ert/dark_storage/common.py +++ b/src/ert/dark_storage/common.py @@ -118,7 +118,8 @@ def data_for_key( response_key = next((k for k in response_key_to_response_type if k == key), None) if response_key is None: response_key = next( - (k for k in response_key_to_response_type if k in key), None + (k for k in response_key_to_response_type if k in key and key != f"{k}H"), + None, ) if response_key is not None: diff --git a/tests/ert/unit_tests/dark_storage/test_common.py b/tests/ert/unit_tests/dark_storage/test_common.py index ee4321bebea..9249596ac8c 100644 --- a/tests/ert/unit_tests/dark_storage/test_common.py +++ b/tests/ert/unit_tests/dark_storage/test_common.py @@ -1,3 +1,5 @@ +import datetime + import pandas as pd import polars import pytest @@ -73,6 +75,32 @@ def test_data_for_key_gives_mean_for_duplicate_values(tmp_path): ) +def test_data_for_key_doesnt_mistake_history_for_response(tmp_path): + with open_storage(tmp_path / "storage", mode="w") as storage: + summary_config = SummaryConfig( + name="summary", input_files=["CASE"], keys=["FGPR"] + ) + experiment = storage.create_experiment(responses=[summary_config]) + ensemble = experiment.create_ensemble(name="ensemble", ensemble_size=1) + ensemble.save_response( + "summary", + polars.DataFrame( + { + "response_key": ["FGPR", "FGPR"], + "time": polars.Series( + [datetime.datetime(2000, 1, 1), datetime.datetime(2000, 1, 2)], + dtype=polars.Datetime("ms"), + ), + "values": polars.Series([0.0, 1.0], dtype=polars.Float32), + } + ), + 0, + ) + ensemble.refresh_ensemble_state() + + assert data_for_key(ensemble, "FGPRH").empty + + def test_data_for_key_returns_empty_gen_data_config(tmp_path): with open_storage(tmp_path / "storage", mode="w") as storage: gen_data_config = GenDataConfig(keys=["response"])