From c57b5e15720eb656c2150a109b8b88b8229a09a5 Mon Sep 17 00:00:00 2001 From: Jon Holba Date: Thu, 14 Mar 2024 10:19:07 +0100 Subject: [PATCH] Replace usage of a deprecated function in a test --- tests/unit_tests/test_summary_response.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/unit_tests/test_summary_response.py b/tests/unit_tests/test_summary_response.py index 5e2895cf767..46d5139088a 100644 --- a/tests/unit_tests/test_summary_response.py +++ b/tests/unit_tests/test_summary_response.py @@ -1,4 +1,3 @@ -import os import shutil from pathlib import Path from textwrap import dedent @@ -26,7 +25,6 @@ def test_load_summary_response_restart_not_zero(tmpdir, snapshot, request, stora ) with open("config.ert", "w", encoding="utf-8") as fh: fh.writelines(config) - cwd = Path().absolute() sim_path = Path("simulations") / "realization-0" / "iter-0" ert_config = ErtConfig.from_file("config.ert") @@ -49,15 +47,19 @@ def test_load_summary_response_restart_not_zero(tmpdir, snapshot, request, stora ) create_run_path(prior, ert_config) - os.chdir(sim_path) - shutil.copy(test_path / "PRED_RUN.SMSPEC", "PRED_RUN.SMSPEC") - shutil.copy(test_path / "PRED_RUN.UNSMRY", "PRED_RUN.UNSMRY") - os.chdir(cwd) + shutil.copy(test_path / "PRED_RUN.SMSPEC", sim_path / "PRED_RUN.SMSPEC") + shutil.copy(test_path / "PRED_RUN.UNSMRY", sim_path / "PRED_RUN.UNSMRY") facade = LibresFacade.from_config_file("config.ert") facade.load_from_forward_model(ensemble, [True], 0) + df = ensemble.load_responses("summary", (0,)).to_dataframe() + df = df.unstack(level="name") + df.columns = [col[1] for col in df.columns.values] + df.index = df.index.rename( + {"time": "Date", "realization": "Realization"} + ).reorder_levels(["Realization", "Date"]) snapshot.assert_match( - ensemble.load_all_summary_data().dropna().iloc[:, :15].to_csv(), + df.dropna().iloc[:, :15].to_csv(), "summary_restart", )