-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
199 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
tests/ert/unit_tests/sensitivity_analysis/test_design_matrix.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import time | ||
|
||
import pandas as pd | ||
import pytest | ||
|
||
from ert.config import ErtConfig | ||
|
||
|
||
@pytest.mark.usefixtures("copy_poly_case") | ||
def test_reading_design_matrix(copy_poly_case): | ||
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 DESIGN_SHEET:DesignSheet01 DEFAULT_SHEET:DefaultValues" | ||
) | ||
ert_config = ErtConfig.from_file("poly.ert") | ||
parameter_configurations = ert_config.ensemble_config.parameter_configuration | ||
t = time.perf_counter() | ||
_design_frame = ert_config.analysis_config.design_matrix.read_design_matrix( | ||
parameter_configurations | ||
) | ||
print(f"Read design matrix time_used {(time.perf_counter() - t):.4f}s") |