Skip to content

Commit

Permalink
TST: Remove deprecated useage from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Dec 9, 2021
1 parent aae4279 commit 638f351
Show file tree
Hide file tree
Showing 20 changed files with 118 additions and 120 deletions.
14 changes: 6 additions & 8 deletions tests/test_cube/test_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@pytest.fixture()
def loadsfile1():
"""Fixture for loading a SFILE1"""
return Cube(SFILE1)
return xtgeo.cube_from_file(SFILE1)


def test_create():
Expand Down Expand Up @@ -108,10 +108,8 @@ def test_segy_export_import(tmpdir):
def test_storm_import(tmpdir):
"""Import Cube using Storm format (case Reek)."""

acube = Cube()

st1 = xtg.timer()
acube.from_file(SFILE3, fformat="storm")
acube = xtgeo.cube_from_file(SFILE3, fformat="storm")
elapsed = xtg.timer(st1)
logger.info("Reading Storm format took %s", elapsed)

Expand Down Expand Up @@ -165,7 +163,7 @@ def test_segyio_import_export(tmpdir, pristine):
input_cube.to_file(join(tmpdir, "reek_cube.segy"), pristine=pristine)

# reread that file
read_cube = Cube(join(tmpdir, "reek_cube.segy"))
read_cube = xtgeo.cube_from_file(join(tmpdir, "reek_cube.segy"))
assert input_cube.dimensions == read_cube.dimensions
assert input_cube.values.flatten().tolist() == read_cube.values.flatten().tolist()

Expand Down Expand Up @@ -227,7 +225,7 @@ def test_cube_thinning(tmpdir, loadsfile1):

incube.to_file(join(tmpdir, "cube_thinned.segy"))

incube2 = Cube(join(tmpdir, "cube_thinned.segy"))
incube2 = xtgeo.cube_from_file(join(tmpdir, "cube_thinned.segy"))
logger.info(incube2)


Expand Down Expand Up @@ -275,7 +273,7 @@ def test_cube_swapaxes():

logger.info("Import SEGY format via SEGYIO")

incube = Cube(SFILE4)
incube = xtgeo.cube_from_file(SFILE4)
logger.info(incube)
val1 = incube.values.copy()

Expand All @@ -292,7 +290,7 @@ def test_cube_swapaxes():
def test_cube_randomline(show_plot):
"""Import a cube, and compute a randomline given a simple Polygon"""

incube = Cube(SFILE4)
incube = xtgeo.cube_from_file(SFILE4)

poly = xtgeo.Polygons()
poly.from_list([[778133, 6737650, 2000, 1], [776880, 6738820, 2000, 1]])
Expand Down
9 changes: 5 additions & 4 deletions tests/test_cube/test_cube_xtgformats_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

@pytest.mark.benchmark(group="import/export")
def test_benchmark_cube_export(benchmark, tmp_path, testpath):
cube1 = xtgeo.Cube(
cube1 = xtgeo.cube_from_file(
join(testpath, "cubes/reek/syntseis_20030101_seismic_depth_stack.segy")
)

Expand All @@ -29,17 +29,18 @@ def write():

@pytest.mark.benchmark(group="import/export")
def test_benchmark_cube_import(benchmark, testpath, tmp_path):
cube1 = xtgeo.Cube(
cube1 = xtgeo.cube_from_file(
join(testpath, "cubes/reek/syntseis_20030101_seismic_depth_stack.segy")
)

fname = join(tmp_path, "syntseis_20030101_seismic_depth_stack.xtgrecube")
cube1.to_file(fname, fformat="xtgregcube")

cube2 = xtgeo.Cube()
cube2 = None

def read():
cube2.from_file(fname, fformat="xtgregcube")
nonlocal cube2
cube2 = xtgeo.cube_from_file(fname, fformat="xtgregcube")

benchmark(read)

Expand Down
6 changes: 2 additions & 4 deletions tests/test_grid3d/test_deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ def any_gridprop(any_grid):


@pytest.fixture
def any_gridproperties(any_grid, any_gridprop):
gps = GridProperties(*any_grid.dimensions)
gps.append_props([any_gridprop])
return gps
def any_gridproperties(any_gridprop):
return GridProperties(props=[any_gridprop])


def test_gridproperties_init_deprecations(any_gridprop):
Expand Down
18 changes: 8 additions & 10 deletions tests/test_grid3d/test_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@

@pytest.fixture()
def emerald_grid(testpath):
return xtgeo.grid3d.Grid(join(testpath, "3dgrids/eme/1/emerald_hetero_grid.roff"))
return xtgeo.grid_from_file(
join(testpath, "3dgrids/eme/1/emerald_hetero_grid.roff")
)


def test_import_wrong_format(tmp_path):
Expand Down Expand Up @@ -193,8 +195,7 @@ def test_roffbin_import_v2stress():
"""Test roff binary import ROFF using new API, comapre timing etc."""
t0 = xtg.timer()
for _ino in range(100):
grd1 = Grid()
grd1.from_file(REEKFIL4)
xtgeo.grid_from_file(REEKFIL4)
t1 = xtg.timer(t0)
print("100 loops with ROXAPIV 2 took: ", t1)

Expand Down Expand Up @@ -222,7 +223,7 @@ def test_roff_bin_vs_ascii_export(tmp_path):
grd1.to_file(tmp_path / "b6_export.roffasc", fformat="roff_asc")
grd1.to_file(tmp_path / "b6_export.roffbin", fformat="roff_bin")

grd2 = Grid(tmp_path / "b6_export.roffbin")
grd2 = xtgeo.grid_from_file(tmp_path / "b6_export.roffbin")
cell1 = grd1.get_xyz_cell_corners((2, 2, 2))
cell2 = grd2.get_xyz_cell_corners((2, 2, 2))

Expand Down Expand Up @@ -274,9 +275,7 @@ def test_import_grdecl_and_bgrdecl():

def test_eclgrid_import2(tmp_path):
"""Eclipse EGRID import, also change ACTNUM."""
grd = Grid()
logger.info("Import Eclipse GRID...")
grd.from_file(REEKFILE, fformat="egrid")
grd = xtgeo.grid_from_file(REEKFILE, fformat="egrid")

assert grd.ncol == 40, "EGrid NX from Eclipse"
assert grd.nrow == 64, "EGrid NY from Eclipse"
Expand Down Expand Up @@ -320,7 +319,7 @@ def test_eclgrid_import3(tmp_path):

def test_geometrics_reek():
"""Import Reek and test geometrics."""
grd = Grid(REEKFILE, fformat="egrid")
grd = xtgeo.grid_from_file(REEKFILE, fformat="egrid")

geom = grd.get_geometrics(return_dict=True, cellcenter=False)

Expand Down Expand Up @@ -429,8 +428,7 @@ def test_xyz_cell_corners():

def test_grid_layer_slice():
"""Test grid slice coordinates."""
grd = Grid()
grd.from_file(REEKFILE)
grd = xtgeo.grid_from_file(REEKFILE)

sarr1, _ibarr = grd.get_layer_slice(1)
sarrn, _ibarr = grd.get_layer_slice(grd.nlay, top=False)
Expand Down
12 changes: 8 additions & 4 deletions tests/test_grid3d/test_grid_fence.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
def test_randomline_fence_from_well(show_plot):
"""Import ROFF grid with props and make fences"""

grd = xtgeo.Grid(REEKROOT, fformat="eclipserun", initprops=["PORO"])
wll = xtgeo.Well(WELL1, zonelogname="Zonelog")
grd = xtgeo.grid_from_file(REEKROOT, fformat="eclipserun", initprops=["PORO"])
wll = xtgeo.well_from_file(WELL1, zonelogname="Zonelog")

print(grd.describe(details=True))

Expand Down Expand Up @@ -58,7 +58,9 @@ def test_randomline_fence_from_well(show_plot):
def test_randomline_fence_from_polygon(show_plot):
"""Import ROFF grid with props and make fence from polygons"""

grd = xtgeo.Grid(REEKROOT, fformat="eclipserun", initprops=["PORO", "PERMX"])
grd = xtgeo.grid_from_file(
REEKROOT, fformat="eclipserun", initprops=["PORO", "PERMX"]
)
fence = xtgeo.Polygons(FENCE1)

# get the polygons
Expand Down Expand Up @@ -100,7 +102,9 @@ def test_randomline_fence_from_polygon(show_plot):
def test_randomline_fence_calczminzmax():
"""Import ROFF grid with props and make fence from polygons, zmin/zmax auto"""

grd = xtgeo.Grid(REEKROOT, fformat="eclipserun", initprops=["PORO", "PERMX"])
grd = xtgeo.grid_from_file(
REEKROOT, fformat="eclipserun", initprops=["PORO", "PERMX"]
)
fence = xtgeo.Polygons(FENCE1)

fspec = fence.get_fence(distance=5, nextend=2, asnumpy=True)
Expand Down
Loading

0 comments on commit 638f351

Please sign in to comment.