Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove table_index_values #376

Merged
merged 3 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 2 additions & 22 deletions src/fmu/dataio/_objectdata_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@

try:
import pyarrow as pa # type: ignore
import pyarrow.compute as pc
except ImportError:
HAS_PYARROW = False
else:
Expand Down Expand Up @@ -275,9 +274,7 @@ def _derive_objectdata(self):

elif isinstance(self.obj, pd.DataFrame):
result["table_index"] = self._derive_index()
result["table_index_values"] = self._derive_values_from_index(
result["table_index"]
)

result["subtype"] = "DataFrame"
result["classname"] = "table"
result["layout"] = "table"
Expand All @@ -290,9 +287,7 @@ def _derive_objectdata(self):

elif HAS_PYARROW and isinstance(self.obj, pa.Table):
result["table_index"] = self._derive_index()
result["table_index_values"] = self._derive_values_from_index(
result["table_index"]
)

result["subtype"] = "ArrowTable"
result["classname"] = "table"
result["layout"] = "table"
Expand Down Expand Up @@ -517,20 +512,6 @@ def _get_columns(self):
logger.debug("Available columns in table %s ", columns)
return columns

def _derive_values_from_index(self, table_index):
"""Get unique values in table_index columns"""
index_values = {}
for index_name in table_index:
if isinstance(self.obj, pd.DataFrame):
logger.debug("pandas")
index_values[index_name] = self.obj[index_name].unique()
else:
logger.debug("arrow")
index_values[index_name] = pc.unique(
self.obj.column(index_name)
).tolist()
return index_values

def _derive_index(self):
"""Derive table index"""
# This could in the future also return context
Expand Down Expand Up @@ -720,7 +701,6 @@ def derive_metadata(self):
meta["spec"] = objres["spec"]
meta["bbox"] = objres["bbox"]
meta["table_index"] = objres.get("table_index")
meta["table_index_values"] = objres.get("table_index_values")
meta["undef_is_zero"] = self.dataio.undef_is_zero

# timedata:
Expand Down
1 change: 0 additions & 1 deletion src/fmu/dataio/dataio.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,6 @@ class ExportData:
vertical_domain: dict = field(default_factory=dict)
workflow: str = ""
table_index: Optional[list] = None
table_index_values: Optional[dict] = None

# some keys that are modified version of input, prepended with _use
_usecontent: dict = field(default_factory=dict, init=False)
Expand Down
37 changes: 0 additions & 37 deletions tests/test_units/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,43 +143,6 @@ def test_table_index_real_summary(edataobj3, drogon_summary):
assert res["table_index"] == ["DATE"], "Incorrect table index "


def test_table_index_values_real_volumes(edataobj3, drogon_volumes):
"""Test setting of table_index and table_index_values in real inplace volume file

Args:
edataobj3 (_type_): _description_
drogon_volumes (_type_): _description_
"""
objdata = _ObjectDataProvider(drogon_volumes, edataobj3)
res = objdata._derive_objectdata()
correct_answers = {
"ZONE": ["Valysar", "Therys", "Volon"],
"REGION": [
"WestLowland",
"CentralSouth",
"CentralNorth",
"NorthHorst",
"CentralRamp",
"CentralHorst",
"EastLowland",
],
"FACIES": [
"Floodplain",
"Channel",
"Crevasse",
"Coal",
"Calcite",
"Offshore",
"Lowershoreface",
"Uppershoreface",
],
}

for col_name, answer_list in correct_answers.items():
index_items = res["table_index_values"][col_name]
assert_list_and_answer(index_items, answer_list, col_name)


def test_table_wellpicks(wellpicks, globalconfig1):
"""Test export of wellpicks"""

Expand Down
Loading