Skip to content

Commit

Permalink
FIX: Re-add 'timeseries' index without duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
mferrera committed Dec 6, 2024
1 parent 1ee1966 commit 0dcea13
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/fmu/dataio/_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class ExportFolder(str, Enum):
STANDARD_TABLE_INDEX_COLUMNS: Final[dict[str, list[str]]] = {
"volumes": ["ZONE", "REGION", "FACIES", "LICENCE"],
"rft": ["measured_depth", "well", "time"],
"timeseries": ["DATE"],
"simulationtimeseries": ["DATE"],
"wellpicks": ["WELL", "HORIZON"],
}
2 changes: 1 addition & 1 deletion src/fmu/dataio/providers/objectdata/_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _derive_index(table_index: list[str] | None, columns: list[str]) -> list[str
logger.debug("Finding index to include")
for context, standard_cols in STANDARD_TABLE_INDEX_COLUMNS.items():
for valid_col in standard_cols:
if valid_col in columns:
if valid_col in columns and valid_col not in index:
index.append(valid_col)
if index:
logger.info("Context is %s ", context)
Expand Down
12 changes: 12 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,18 @@ def fixture_edataobj3(globalconfig1):
)


@pytest.fixture
def export_data_obj_timeseries(globalconfig1):
"""Combined globalconfig and settings to instance, for internal testing"""

return ExportData(
config=globalconfig1,
name="some timeseries",
content="timeseries",
tagname="",
)


@pytest.fixture(name="mock_summary")
def fixture_summary():
"""Return summary mock data
Expand Down
11 changes: 11 additions & 0 deletions tests/test_units/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ def test_set_table_index_not_in_table(
assert k_err.value.args[0] == "banana is not in table"


def test_table_index_timeseries(export_data_obj_timeseries, drogon_summary):
"""Test setting of table_index in an arbitrary timeseries.
Args:
edataobj3 (dict): metadata
drogon_summary (pd.Dataframe): dataframe with summary data from sumo
"""
objdata = objectdata_provider_factory(drogon_summary, export_data_obj_timeseries)
assert objdata.table_index == ["DATE"], "Incorrect table index "


def test_table_index_real_summary(edataobj3, drogon_summary):
"""Test setting of table_index in real summary file
Expand Down

0 comments on commit 0dcea13

Please sign in to comment.