Skip to content

Commit

Permalink
fix_incorrect_gen_kw_fetching_in_plot_api
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Oct 11, 2024
1 parent 516d088 commit 94ee1ae
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ert/dark_storage/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def data_for_key(
data = dataframe.sort_index(axis=1)
if data.empty:
return pd.DataFrame()
data = data[key].to_frame().dropna()
data = data[key + ":key"].to_frame().dropna()
data.columns = pd.Index([0])
try:
return data.astype(float)
Expand Down
20 changes: 19 additions & 1 deletion tests/ert/unit_tests/gui/tools/plot/test_plot_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pandas as pd
import polars
import pytest
import xarray as xr
from pandas.testing import assert_frame_equal
from starlette.testclient import TestClient

Expand Down Expand Up @@ -253,13 +254,30 @@ def test_plot_api_handles_empty_gen_kw(tmp_path, monkeypatch):
template_file=None,
output_file=None,
transform_function_definitions=[],
)
),
],
responses=[],
observations={},
)
ensemble = storage.create_ensemble(experiment.id, ensemble_size=10)
assert api.data_for_key(str(ensemble.id), key).empty
ensemble.save_parameters(
key,
1,
xr.Dataset(
{
"values": ("names", [1.0]),
"transformed_values": ("names", [1.0]),
"names": ["key"],
}
),
)
assert api.data_for_key(str(ensemble.id), key).to_csv() == dedent(
"""\
Realization,0
1,1.0
"""
)
if enkf._storage is not None:
enkf._storage.close()
enkf._storage = None
Expand Down

0 comments on commit 94ee1ae

Please sign in to comment.