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

Update well log import and re-apply tests for MacOS #1194

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion src/xtgeo/well/_well_io.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Well input and ouput, private module"""

import json
from collections.abc import Iterable
from copy import deepcopy

import numpy as np
Expand Down Expand Up @@ -292,7 +293,7 @@ def import_wlogs(wlogs: dict):
else:
raise ValueError(f"Invalid log type found in input: {typ}")

if rec is None or isinstance(rec, dict):
if rec is None or isinstance(rec, Iterable):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option could be isinstance(rec, (dict, list)). Iterable will accomplish the same thing with a bit of a broader scope (also including set etc) so I think this is fine.

wlogrecords[key] = deepcopy(rec)
else:
raise ValueError(f"Invalid log record found in input: {rec}")
Expand Down
44 changes: 21 additions & 23 deletions tests/test_well/test_well.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,29 +259,27 @@ def test_shortwellname(create_well):
assert short == "A-142H"


# @pytest.mark.skipif(sys.platform.startswith("darwin"), reason="No pytables on macOS")
# def test_hdf_io_single(tmp_path):
# """Test HDF io, single well."""
# mywell = xtgeo.well_from_file(WELL1)

# wname = (tmp_path / "hdfwell").with_suffix(".hdf")
# mywell.to_hdf(wname)
# mywell2 = xtgeo.well_from_file(wname, fformat="hdf")
# assert mywell2.nrow == mywell.nrow


# @pytest.mark.skipif(sys.platform.startswith("darwin"), reason="No pytables on macOS")
# def test_import_as_rms_export_as_hdf_many(tmp_path, simple_well):
# """Import RMS and export as HDF5 and RMS asc, many, and compare timings."""
# t0 = xtg.timer()
# wname = (tmp_path / "$random").with_suffix(".hdf")
# wuse = simple_well.to_hdf(wname, compression=None)
# print("Time for save HDF: ", xtg.timer(t0))

# t0 = xtg.timer()
# result = xtgeo.well_from_file(wuse, fformat="hdf5")
# assert result.get_dataframe().equals(simple_well.get_dataframe())
# print("Time for load HDF: ", xtg.timer(t0))
def test_hdf_io_single(tmp_path, testdata_path):
"""Test HDF io, single well."""
mywell = xtgeo.well_from_file(testdata_path / WELL1)

wname = (tmp_path / "hdfwell").with_suffix(".hdf")
mywell.to_hdf(wname)
mywell2 = xtgeo.well_from_file(wname, fformat="hdf")
assert mywell2.nrow == mywell.nrow


def test_import_as_rms_export_as_hdf_many(tmp_path, simple_well):
"""Import RMS and export as HDF5 and RMS asc, many, and compare timings."""
t0 = xtg.timer()
wname = (tmp_path / "$random").with_suffix(".hdf")
wuse = simple_well.to_hdf(wname, compression=None)
print("Time for save HDF: ", xtg.timer(t0))

t0 = xtg.timer()
result = xtgeo.well_from_file(wuse, fformat="hdf5")
assert result.get_dataframe().equals(simple_well.get_dataframe())
print("Time for load HDF: ", xtg.timer(t0))


def test_import_export_rmsasc(tmp_path, simple_well):
Expand Down
Loading