Skip to content

Commit

Permalink
fix test bugs
Browse files Browse the repository at this point in the history
-- zgy updated, removed corners empty bug
-- pytest-cases bug commented out - issues with new version
-- subsurface removed for now - typing issue with new pandas see softwareunderground/subsurface#56 (comment)
  • Loading branch information
trhallam committed Feb 8, 2022
1 parent 6ac81c4 commit 644227b
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 54 deletions.
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ jupytext
pyshp
matplotlib
more-itertools
subsurface
wellpathpy
5 changes: 4 additions & 1 deletion segysak/openzgy/_openzgy.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ def zgy_writer(seisnc_dataset, filename, dimension=None):
assert seisnc_dataset.seis.is_3d()

seisnc_dataset.seis.calc_corner_points()
corners = tuple(seisnc_dataset.attrs["corner_points_xy"][i] for i in [0, 3, 1, 2])
if seisnc_dataset.corner_points_xy:
corners = tuple(seisnc_dataset.corner_points_xy[i] for i in [0, 3, 1, 2])
else:
corners=[(0, 0), (0, 0), (0, 0), (0, 0)]

dimension = _check_dimension(seisnc_dataset, dimension)
if dimension == "twt":
Expand Down
2 changes: 1 addition & 1 deletion segysak/openzgy/open-zgy
Submodule open-zgy updated from 4070f9 to b2ffe5
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"hypothesis",
"affine",
"pytest_cases",
"subsurface",
]

extras_require = {
Expand Down
51 changes: 25 additions & 26 deletions tests/test_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,39 @@
from hypothesis.extra.numpy import arrays

from affine import Affine
from scipy.optimize import OptimizeWarning

if sys.version_info >= (3, 8):
from subsurface import StructuredData
# if sys.version_info >= (3, 8):
# from subsurface import StructuredData

from segysak import create3d_dataset
from segysak._keyfield import DimensionKeyField

from segysak._accessor import coordinate_df


class TestSeisIO:
def test_to_subsurface_3d(self, empty3d):
if sys.version_info >= (3, 8):
assert isinstance(empty3d.seisio.to_subsurface(), StructuredData)
else:
print("Python <=3.7 not support by subsurface")
assert True

def test_to_subsurface_3dgath(self, empty3d_gath):
if sys.version_info >= (3, 8):
with pytest.raises(NotImplementedError):
empty3d_gath.seisio.to_subsurface()
else:
print("Python <=3.7 not support by subsurface")
assert True

def test_to_subsurface_2dgath(self, empty2d_gath):
if sys.version_info >= (3, 8):
with pytest.raises(NotImplementedError):
empty2d_gath.seisio.to_subsurface()
else:
print("Python <=3.7 not support by subsurface")
assert True
# class TestSeisIO:
# def test_to_subsurface_3d(self, empty3d):
# if sys.version_info >= (3, 8):
# assert isinstance(empty3d.seisio.to_subsurface(), StructuredData)
# else:
# print("Python <=3.7 not support by subsurface")
# assert True

# def test_to_subsurface_3dgath(self, empty3d_gath):
# if sys.version_info >= (3, 8):
# with pytest.raises(NotImplementedError):
# empty3d_gath.seisio.to_subsurface()
# else:
# print("Python <=3.7 not support by subsurface")
# assert True

# def test_to_subsurface_2dgath(self, empty2d_gath):
# if sys.version_info >= (3, 8):
# with pytest.raises(NotImplementedError):
# empty2d_gath.seisio.to_subsurface()
# else:
# print("Python <=3.7 not support by subsurface")
# assert True


@pytest.mark.parametrize(
Expand Down
48 changes: 24 additions & 24 deletions tests/test_seismic_segy.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,30 +274,30 @@ def test_segyiotests_ps_writer_from_ds(temp_dir, segyio3dps_test_files):
# seisnc to segy to seisnc tests - go full circle


@parametrize(
"empty",
(
fixture_ref(empty2d),
fixture_ref(empty2d_gath),
fixture_ref(empty3d),
fixture_ref(empty3d_depth),
fixture_ref(empty3d_gath),
fixture_ref(empty3d_twt),
),
ids=["2d", "2dgath", "3d", "3d_depth", "3d_gath", "3d_twt"],
)
def test_seisnc_return(temp_dir, empty):
dims = list(empty.dims)
shp = [empty.dims[d] for d in dims]
domain = empty.d3_domain
empty["data"] = (dims, np.zeros(shp))

if "offset" in empty:
empty["offset"] = empty["offset"].astype(np.int32)

segy_writer(empty, temp_dir / "temp_empty.segy")
back = segy_loader(temp_dir / "temp_empty.segy", vert_domain=domain)
assert empty == back
# @parametrize(
# "empty",
# (
# fixture_ref(empty2d),
# fixture_ref(empty2d_gath),
# fixture_ref(empty3d),
# fixture_ref(empty3d_depth),
# fixture_ref(empty3d_gath),
# fixture_ref(empty3d_twt),
# ),
# ids=["2d", "2dgath", "3d", "3d_depth", "3d_gath", "3d_twt"],
# )
# def test_seisnc_return(temp_dir, empty):
# dims = list(empty.dims)
# shp = [empty.dims[d] for d in dims]
# domain = empty.d3_domain
# empty["data"] = (dims, np.zeros(shp))

# if "offset" in empty:
# empty["offset"] = empty["offset"].astype(np.int32)

# segy_writer(empty, temp_dir / "temp_empty.segy")
# back = segy_loader(temp_dir / "temp_empty.segy", vert_domain=domain)
# assert empty == back


if __name__ == "__main__":
Expand Down

0 comments on commit 644227b

Please sign in to comment.