From 1e9994fe94d8bca1c694fb0a93bd587d7478c848 Mon Sep 17 00:00:00 2001 From: "Yngve S. Kristiansen" Date: Wed, 18 Dec 2024 08:16:17 +0100 Subject: [PATCH] Fix key error on empty summary observations in plotter Co-authored-by: Eivind Jahren --- src/ert/dark_storage/common.py | 2 +- tests/ert/unit_tests/gui/tools/plot/test_plot_api.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ert/dark_storage/common.py b/src/ert/dark_storage/common.py index c1477cad39d..d4525a29af8 100644 --- a/src/ert/dark_storage/common.py +++ b/src/ert/dark_storage/common.py @@ -291,7 +291,7 @@ def get_observation_keys_for_response( elif ( displayed_response_key - in ensemble.experiment.response_type_to_response_keys["summary"] + in ensemble.experiment.response_type_to_response_keys.get("summary", {}) ): response_key = displayed_key_to_response_key["summary"](displayed_response_key)[ 0 diff --git a/tests/ert/unit_tests/gui/tools/plot/test_plot_api.py b/tests/ert/unit_tests/gui/tools/plot/test_plot_api.py index 49ebfddd3a4..d7adfaf5922 100644 --- a/tests/ert/unit_tests/gui/tools/plot/test_plot_api.py +++ b/tests/ert/unit_tests/gui/tools/plot/test_plot_api.py @@ -326,3 +326,14 @@ def test_that_multiple_observations_are_parsed_correctly(api): ensemble = next(x for x in api.get_all_ensembles() if x.id == "ens_id_5") obs_data = api.observations_for_key([ensemble.id], "WOPR:OP1") assert obs_data.shape == (3, 6) + + +def test_that_observations_for_empty_ensemble_returns_empty_data(api_and_storage): + api, storage = api_and_storage + experiment = storage.create_experiment( + parameters=[], + responses=[SummaryConfig(name="summary", input_files=[""], keys=["NAIMFRAC"])], + observations={}, + ) + ensemble = storage.create_ensemble(experiment.id, ensemble_size=1) + assert api.observations_for_key([str(ensemble.id)], "NAIMFRAC").empty