Skip to content

Commit

Permalink
[summary] FIX: Ensure index name is retained (#424)
Browse files Browse the repository at this point in the history
[summary] FIX: Ensure index name `DATE` is retained when using `TIMESTEP` to improve index `DATE` index resolution
  • Loading branch information
alifbe authored Oct 14, 2022
1 parent df10aa0 commit 198a511
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ecl2df/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def _ensure_unique_datetime_index(dframe: pd.DataFrame) -> pd.DataFrame:
"Dataframe of smry data contained duplicate timestamps",
"Vector TIMESTEP exists, but unit could not be identified",
)
dframe.index = index_as_list
dframe.index = pd.Series(data=index_as_list, name=dframe.index.name)
else:
raise ValueError(
"Dataframe of smry data contained duplicate timestamps due to limited.",
Expand Down
12 changes: 12 additions & 0 deletions tests/test_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,18 @@ def test_unique_datetime_for_short_timesteps(filepath):
assert summary.df(EclFiles(filepath)).index.is_unique


@pytest.mark.parametrize(
"filepath",
[
SHORT_STEP_WITH_TIMESTEP,
SHORT_STEP_WITH_TIMESTEP_LONG,
],
)
def test_unique_datetime_retain_index_name(filepath):
"""Test _ensure_unique_datetime_index method retain index name"""
assert summary.df(EclFiles(filepath)).index.name == "DATE"


def test_smry_meta():
"""Test obtaining metadata dictionary for summary vectors from an EclSum object"""
meta = smry_meta(EclFiles(REEK))
Expand Down

0 comments on commit 198a511

Please sign in to comment.