Skip to content

Commit

Permalink
Improve test and remove designmatrix
Browse files Browse the repository at this point in the history
  • Loading branch information
larsevj committed Sep 24, 2024
1 parent 4aed4b9 commit 9fdf08b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 23 deletions.
Binary file removed test-data/ert/poly_example/design_matrix.xlsx
Binary file not shown.
1 change: 0 additions & 1 deletion test-data/ert/poly_example/poly.ert
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ RUNPATH poly_out/realization-<IENS>/iter-<ITER>
OBS_CONFIG observations
REALIZATION_MEMORY 50mb

DESIGN_MATRIX design_matrix.xlsx
NUM_REALIZATIONS 100
MIN_REALIZATIONS 1

Expand Down
34 changes: 12 additions & 22 deletions tests/ert/unit_tests/sensitivity_analysis/test_design_matrix.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pandas as pd
import pytest

from ert.config import ErtConfig
Expand All @@ -10,28 +11,17 @@

@pytest.mark.usefixtures("copy_poly_case")
def test_design_matrix(copy_poly_case):
config_text = """
QUEUE_SYSTEM LOCAL
QUEUE_OPTION LOCAL MAX_RUNNING 50
RUNPATH poly_out/realization-<IENS>/iter-<ITER>
OBS_CONFIG observations
REALIZATION_MEMORY 50mb
DESIGN_MATRIX design_matrix.xlsx
NUM_REALIZATIONS 100
MIN_REALIZATIONS 1
GEN_KW COEFFS coeff_priors
GEN_DATA POLY_RES RESULT_FILE:poly.out
INSTALL_JOB poly_eval POLY_EVAL
FORWARD_MODEL poly_eval
"""
with open("my_config.ert", "w", encoding="utf-8") as fhandle:
fhandle.write(config_text)
ert_config = ErtConfig.from_file("my_config.ert")
design_matrix_df = pd.DataFrame(
{"REAL": [0, 1, 2], "a": [1, 2, 3], "b": [0, 2, 0], "c": [3, 1, 3]}
)
default_sheet_df = pd.DataFrame()
with pd.ExcelWriter("design_matrix.xlsx") as xl_write:
design_matrix_df.to_excel(xl_write, index=False, sheet_name="DesignSheet01")
default_sheet_df.to_excel(xl_write, index=False, sheet_name="DefaultValues")

with open("poly.ert", "a", encoding="utf-8") as fhandle:
fhandle.write("DESIGN_MATRIX design_matrix.xlsx")
ert_config = ErtConfig.from_file("poly.ert")
with open_storage(ert_config.ens_path, mode="w") as ert_storage:
design_frame = read_design_matrix(ert_config, "design_matrix.xlsx")
_ensemble = initialize_parameters(
Expand Down

0 comments on commit 9fdf08b

Please sign in to comment.