diff --git a/tests/test_cube/test_cube.py b/tests/test_cube/test_cube.py index cde39094d..c3271fbb3 100644 --- a/tests/test_cube/test_cube.py +++ b/tests/test_cube/test_cube.py @@ -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(): @@ -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) @@ -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() @@ -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) @@ -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() @@ -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]]) diff --git a/tests/test_cube/test_cube_xtgformats_io.py b/tests/test_cube/test_cube_xtgformats_io.py index d218e60f8..890b752ea 100644 --- a/tests/test_cube/test_cube_xtgformats_io.py +++ b/tests/test_cube/test_cube_xtgformats_io.py @@ -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") ) @@ -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) diff --git a/tests/test_grid3d/test_deprecations.py b/tests/test_grid3d/test_deprecations.py index 1d66e25f1..66e9bd89f 100644 --- a/tests/test_grid3d/test_deprecations.py +++ b/tests/test_grid3d/test_deprecations.py @@ -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): diff --git a/tests/test_grid3d/test_grid.py b/tests/test_grid3d/test_grid.py index 44394da3f..70816be42 100644 --- a/tests/test_grid3d/test_grid.py +++ b/tests/test_grid3d/test_grid.py @@ -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): @@ -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) @@ -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)) @@ -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" @@ -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) @@ -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) diff --git a/tests/test_grid3d/test_grid_fence.py b/tests/test_grid3d/test_grid_fence.py index 5534d3df1..d184a6f3a 100644 --- a/tests/test_grid3d/test_grid_fence.py +++ b/tests/test_grid3d/test_grid_fence.py @@ -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)) @@ -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 @@ -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) diff --git a/tests/test_grid3d/test_grid_property.py b/tests/test_grid3d/test_grid_property.py index 97c003f0e..35c368a0d 100644 --- a/tests/test_grid3d/test_grid_property.py +++ b/tests/test_grid3d/test_grid_property.py @@ -212,7 +212,7 @@ def test_dtype(): def test_create_from_grid(): """Create a simple property from grid""" - gg = Grid(TESTFILE5, fformat="egrid") + gg = xtgeo.grid_from_file(TESTFILE5, fformat="egrid") poro = GridProperty(gg, name="poro", values=0.33) assert poro.ncol == gg.ncol @@ -236,8 +236,8 @@ def test_create_from_grid(): def test_create_from_gridproperty(): """Create a simple property from grid""" - gg = Grid(TESTFILE5, fformat="egrid") - poro = GridProperty(gg, name="poro", values=0.33) + gg = xtgeo.grid_from_file(TESTFILE5, fformat="egrid") + poro = xtgeo.GridProperty(gg, name="poro", values=0.33) assert poro.ncol == gg.ncol # create from gridproperty @@ -258,8 +258,7 @@ def test_pathlib(tmp_path): """Import and export via pathlib""" pfile = pathlib.Path(DUALROFF) - grdp = GridProperty() - grdp.from_file(pfile, name="POROM") + grdp = xtgeo.gridproperty_from_file(pfile, name="POROM") assert grdp.dimensions == (5, 3, 1) @@ -276,9 +275,7 @@ def test_roffbin_import1(): logger.info("Name is {}".format(__name__)) - x = GridProperty() - logger.info("Import roff...") - x.from_file(TESTFILE1, fformat="roff", name="PORO") + x = xtgeo.gridproperty_from_file(TESTFILE1, fformat="roff", name="PORO") logger.info(repr(x.values)) logger.info(x.values.dtype) @@ -291,9 +288,7 @@ def test_roffbin_import1_new(): """Test ROFF import, new code May 2018""" logger.info("Name is {}".format(__name__)) - x = GridProperty() - logger.info("Import roff...") - x.from_file(TESTFILE1, fformat="roff", name="PORO") + x = xtgeo.gridproperty_from_file(TESTFILE1, fformat="roff", name="PORO") logger.info("Porosity is {}".format(x.values)) logger.info("Mean porosity is {}".format(x.values.mean())) assert x.values.mean() == pytest.approx(0.1677, abs=0.001) @@ -303,17 +298,13 @@ def test_roffbin_import2(): """Import roffbin, with several props in one file.""" logger.info("Name is {}".format(__name__)) - dz = GridProperty() - logger.info("Import roff...") - dz.from_file(TESTFILE2, fformat="roff", name="Z_increment") + dz = xtgeo.gridproperty_from_file(TESTFILE2, fformat="roff", name="Z_increment") logger.info(repr(dz.values)) logger.info(dz.values.dtype) logger.info("Mean DZ is {}".format(dz.values.mean())) - hc = GridProperty() - logger.info("Import roff...") - hc.from_file(TESTFILE2, fformat="roff", name="Oil_HCPV") + hc = xtgeo.gridproperty_from_file(TESTFILE2, fformat="roff", name="Oil_HCPV") logger.info(repr(hc.values)) logger.info(hc.values.dtype) @@ -330,8 +321,8 @@ def test_eclinit_simple_importexport(tmpdir): """Property import and export with anoother name""" # let me guess the format (shall be egrid) - gg = Grid(TESTFILE13A, fformat="egrid") - po = GridProperty(TESTFILE13B, name="PORO", grid=gg) + gg = xtgeo.grid_from_file(TESTFILE13A, fformat="egrid") + po = xtgeo.gridproperty_from_file(TESTFILE13B, name="PORO", grid=gg) po.to_file( os.path.join(tmpdir, "simple.grdecl"), @@ -340,38 +331,50 @@ def test_eclinit_simple_importexport(tmpdir): fmt="%12.5f", ) - p2 = GridProperty(os.path.join(tmpdir, "simple.grdecl"), grid=gg, name="PORO2") + p2 = xtgeo.gridproperty_from_file( + os.path.join(tmpdir, "simple.grdecl"), grid=gg, name="PORO2" + ) assert p2.name == "PORO2" def test_grdecl_import_reek(tmpdir): """Property GRDECL import from Eclipse. Reek""" - rgrid = Grid(TESTFILE12A, fformat="grdecl") + rgrid = xtgeo.grid_from_file(TESTFILE12A, fformat="grdecl") assert rgrid.dimensions == (40, 64, 14) - poro = GridProperty(TESTFILE12B, name="PORO", fformat="grdecl", grid=rgrid) + poro = xtgeo.gridproperty_from_file( + TESTFILE12B, name="PORO", fformat="grdecl", grid=rgrid + ) - poro2 = GridProperty(TESTFILE1, name="PORO", fformat="roff", grid=rgrid) + poro2 = xtgeo.gridproperty_from_file( + TESTFILE1, name="PORO", fformat="roff", grid=rgrid + ) assert poro.values.mean() == pytest.approx(poro2.values.mean(), abs=0.001) assert poro.values.std() == pytest.approx(poro2.values.std(), abs=0.001) with pytest.raises(KeywordNotFoundError): - poro3 = GridProperty(TESTFILE12B, name="XPORO", fformat="grdecl", grid=rgrid) + poro3 = xtgeo.gridproperty_from_file( + TESTFILE12B, name="XPORO", fformat="grdecl", grid=rgrid + ) logger.debug("Keyword failed as expected for instance %s", poro3) # Export to ascii grdecl and import that again... exportfile = os.path.join(tmpdir, "reekporo.grdecl") poro.to_file(exportfile, fformat="grdecl") - porox = GridProperty(exportfile, name="PORO", fformat="grdecl", grid=rgrid) + porox = xtgeo.gridproperty_from_file( + exportfile, name="PORO", fformat="grdecl", grid=rgrid + ) assert poro.values.mean() == pytest.approx(porox.values.mean(), abs=0.001) # Export to binary grdecl and import that again... exportfile = os.path.join(tmpdir, "reekporo.bgrdecl") poro.to_file(exportfile, fformat="bgrdecl") - porox = GridProperty(exportfile, name="PORO", fformat="bgrdecl", grid=rgrid) + porox = xtgeo.gridproperty_from_file( + exportfile, name="PORO", fformat="bgrdecl", grid=rgrid + ) assert poro.values.mean() == pytest.approx(porox.values.mean(), abs=0.001) @@ -379,8 +382,7 @@ def test_io_roff_discrete(tmpdir): """Import ROFF discrete property; then export to ROFF int.""" logger.info("Name is {}".format(__name__)) - po = GridProperty() - po.from_file(TESTFILE8, fformat="roff", name="Zone") + po = xtgeo.gridproperty_from_file(TESTFILE8, fformat="roff", name="Zone") logger.info("\nCodes ({})\n{}".format(po.ncodes, po.codes)) @@ -415,7 +417,7 @@ def test_io_to_nonexisting_folder(grid_property): def test_get_all_corners(): """Get X Y Z for all corners as XTGeo GridProperty objects""" - grid = Grid(TESTFILE8A) + grid = xtgeo.grid_from_file(TESTFILE8A) allc = grid.get_xyz_corners() x0 = allc[0] @@ -438,7 +440,7 @@ def test_get_all_corners(): def test_get_cell_corners(): """Get X Y Z for one cell as tuple""" - grid = Grid(TESTFILE8A) + grid = xtgeo.grid_from_file(TESTFILE8A) clist = grid.get_xyz_cell_corners(ijk=(4, 4, 1)) logger.debug(clist) @@ -448,8 +450,8 @@ def test_get_cell_corners(): def test_get_xy_values_for_webportal(): """Get lists on webportal format""" - grid = Grid(TESTFILE8A) - prop = GridProperty(TESTFILE9, grid=grid, name="PORO") + grid = xtgeo.grid_from_file(TESTFILE8A) + prop = xtgeo.gridproperty_from_file(TESTFILE9, grid=grid, name="PORO") start = xtg.timer() coord, valuelist = prop.get_xy_value_lists(grid=grid) @@ -457,8 +459,8 @@ def test_get_xy_values_for_webportal(): logger.info("Elapsed {}".format(elapsed)) logger.info("Coords {}".format(coord)) - grid = Grid(TESTFILE10) - prop = GridProperty(TESTFILE11, grid=grid, name="PORO") + grid = xtgeo.grid_from_file(TESTFILE10) + prop = xtgeo.gridproperty_from_file(TESTFILE11, grid=grid, name="PORO") coord, valuelist = prop.get_xy_value_lists(grid=grid, activeonly=False) @@ -471,9 +473,7 @@ def test_get_values_by_ijk(): """Test getting values for given input arrays for I J K""" logger.info("Name is {}".format(__name__)) - x = GridProperty() - logger.info("Import roff...") - x.from_file(TESTFILE1, fformat="roff", name="PORO") + x = xtgeo.gridproperty_from_file(TESTFILE1, fformat="roff", name="PORO") iset1 = np.array([np.nan, 23, 22]) jset1 = np.array([np.nan, 23, 19]) @@ -488,10 +488,10 @@ def test_get_values_by_ijk(): def test_values_in_polygon(): """Test replace values in polygons""" - xprop = GridProperty() - logger.info("Import roff...") - grid = Grid(TESTFILE5) - xprop.from_file(TESTFILE1, fformat="roff", name="PORO", grid=grid) + grid = xtgeo.grid_from_file(TESTFILE5) + xprop = xtgeo.gridproperty_from_file( + TESTFILE1, fformat="roff", name="PORO", grid=grid + ) poly = Polygons(POLYFILE) xprop.geometry = grid xorig = xprop.copy() diff --git a/tests/test_grid3d/test_grid_property_grdecl.py b/tests/test_grid3d/test_grid_property_grdecl.py index 470821087..43d93e7ff 100644 --- a/tests/test_grid3d/test_grid_property_grdecl.py +++ b/tests/test_grid3d/test_grid_property_grdecl.py @@ -8,7 +8,6 @@ from numpy.testing import assert_allclose import xtgeo -from xtgeo.grid3d import GridProperty from xtgeo.grid3d._gridprop_import_grdecl import read_grdecl_3d_property from .grid_generator import xtgeo_grids as grids @@ -22,7 +21,7 @@ def test_gridprop_to_from_file_is_identity(tmp_path, grid, data): prop = data.draw(st.sampled_from(grid.get_xyz_corners())) prop.to_file(filepath, fformat="grdecl") - prop_from_file = GridProperty().from_file( + prop_from_file = xtgeo.gridproperty_from_file( filepath, name=prop.name, fformat="grdecl", grid=grid ) diff --git a/tests/test_grid3d/test_grid_property_roff.py b/tests/test_grid3d/test_grid_property_roff.py index cce4ea01b..77d272300 100644 --- a/tests/test_grid3d/test_grid_property_roff.py +++ b/tests/test_grid3d/test_grid_property_roff.py @@ -7,6 +7,7 @@ from hypothesis import HealthCheck, given, settings from hypothesis.extra.numpy import arrays +import xtgeo from xtgeo.grid3d import GridProperty from xtgeo.grid3d._roff_parameter import RoffParameter @@ -78,7 +79,7 @@ def test_roff_prop_read_xtgeo(tmp_path, xtgeo_property): xtgeo_property.to_file(filepath, name=xtgeo_property.name) - xtgeo_property2 = GridProperty().from_file( + xtgeo_property2 = xtgeo.gridproperty_from_file( filepath, name=xtgeo_property.name, ) diff --git a/tests/test_grid3d/test_grid_roff.py b/tests/test_grid3d/test_grid_roff.py index 90ec1b700..019f540ed 100644 --- a/tests/test_grid3d/test_grid_roff.py +++ b/tests/test_grid3d/test_grid_roff.py @@ -159,14 +159,12 @@ def test_to_from_xtgeogrid_format1(xtggrid): @given(roff_grids()) def test_to_from_roffgrid(roff_grid): - xtggrid = Grid() - xtggrid._actnumsv = roff_grid.xtgeo_actnum() - xtggrid._coordsv = roff_grid.xtgeo_coord() - xtggrid._zcornsv = roff_grid.xtgeo_zcorn() - xtggrid._subgrids = roff_grid.xtgeo_subgrids() - xtggrid._ncol = roff_grid.nx - xtggrid._nrow = roff_grid.ny - xtggrid._nlay = roff_grid.nz + xtggrid = Grid( + actnumsv=roff_grid.xtgeo_actnum(), + coordsv=roff_grid.xtgeo_coord(), + zcornsv=roff_grid.xtgeo_zcorn(), + subgrids=roff_grid.xtgeo_subgrids(), + ) roffgrid2 = RoffGrid.from_xtgeo_grid(xtggrid) assert same_geometry(roffgrid2, roff_grid) diff --git a/tests/test_grid3d/test_grid_vs_points.py b/tests/test_grid3d/test_grid_vs_points.py index ff0640c1c..abbdd013e 100644 --- a/tests/test_grid3d/test_grid_vs_points.py +++ b/tests/test_grid3d/test_grid_vs_points.py @@ -121,7 +121,7 @@ def test_get_ijk_from_points_tricky(): def test_get_ijk_from_points(): """Testing getting IJK coordinates from points""" - g1 = xtgeo.grid3d.Grid(REEKGRID) + g1 = xtgeo.grid_from_file(REEKGRID) pointset = [ (456620.790918, 5.935660e06, 1727.649124), # 1, 1, 1 @@ -209,7 +209,7 @@ def test_get_ijk_from_points_smallcase(): def test_get_ijk_from_points_full(): """Testing getting IJK coordinates from points, for all cells""" - g1 = xtgeo.grid3d.Grid(REEKGRID) + g1 = xtgeo.grid_from_file(REEKGRID) df1 = g1.get_dataframe(ijk=True, xyz=False) df2 = g1.get_dataframe(ijk=False, xyz=True) diff --git a/tests/test_grid3d/test_grid_vs_poly.py b/tests/test_grid3d/test_grid_vs_poly.py index 07914b8d9..1527505fa 100644 --- a/tests/test_grid3d/test_grid_vs_poly.py +++ b/tests/test_grid3d/test_grid_vs_poly.py @@ -19,7 +19,7 @@ def test_grid_inactivate_inside(tmpdir): """Inactivate a grid inside polygons""" - g1 = xtgeo.grid3d.Grid(reekgrid) + g1 = xtgeo.grid_from_file(reekgrid) p1 = xtgeo.xyz.Polygons(reekpoly) @@ -41,7 +41,7 @@ def test_grid_inactivate_inside(tmpdir): def test_grid_inactivate_outside(tmpdir): """Inactivate a grid outside polygons""" - g1 = xtgeo.grid3d.Grid(reekgrid) + g1 = xtgeo.grid_from_file(reekgrid) p1 = xtgeo.xyz.Polygons(reekpoly) diff --git a/tests/test_grid3d/test_grid_vs_well.py b/tests/test_grid3d/test_grid_vs_well.py index ad6b1f524..da7c555d7 100644 --- a/tests/test_grid3d/test_grid_vs_well.py +++ b/tests/test_grid3d/test_grid_vs_well.py @@ -7,7 +7,6 @@ import xtgeo from xtgeo.common import XTGeoDialog -from xtgeo.grid3d import GridProperty from xtgeo.well import Well xtg = XTGeoDialog() @@ -109,10 +108,9 @@ def test_report_zlog_mismatch_resultformat3(tmpdir): """Report zone log mismatch grid and well, export updated wellsegment""" g1 = xtgeo.grid_from_file(GRIDFILE) - zo = GridProperty() - zo.from_file(ZONEFILE, name="Zone") + zo = xtgeo.gridproperty_from_file(ZONEFILE, name="Zone") - w1 = Well(WELL1) + w1 = xtgeo.well_from_file(WELL1) res = g1.report_zone_mismatch( well=w1, @@ -133,7 +131,7 @@ def test_report_zlog_mismatch_perflog(tmpdir): zo = xtgeo.gridproperty_from_file(ZONEFILE, name="Zone") - w1 = Well(PWELL1) + w1 = xtgeo.well_from_file(PWELL1) w1.dataframe.to_csv(join(tmpdir, "testw1.csv")) @@ -154,7 +152,7 @@ def test_report_zlog_mismatch_perflog(tmpdir): assert res["TCOUNT2"] == 57 assert res["MCOUNT2"] == 46 - w1 = Well(WELL1) + w1 = xtgeo.well_from_file(WELL1) # well is missing perflog; hence result shall be None res = g1.report_zone_mismatch( diff --git a/tests/test_grid3d/test_gridprop_import_eclrun.py b/tests/test_grid3d/test_gridprop_import_eclrun.py index 84bc31e53..ed12783ce 100644 --- a/tests/test_grid3d/test_gridprop_import_eclrun.py +++ b/tests/test_grid3d/test_gridprop_import_eclrun.py @@ -282,7 +282,7 @@ def test_gridprop_params_no_date(discrete, dtype): def test_match_dualporo(): - grid = xtgeo.Grid() + grid = xtgeo.create_box_grid((4, 3, 5)) grid._dualporo = True grid._dualperm = True actnum = np.ones(grid.dimensions, dtype=np.int32) @@ -319,14 +319,14 @@ def test_gridprop_ecl_run_empty_files(): io.BytesIO(), fformat="init", name="PROP", - grid=xtgeo.Grid(), + grid=xtgeo.create_box_grid((2, 2, 2)), ) with pytest.raises(ValueError, match="Could not find"): xtgeo.gridproperty_from_file( io.BytesIO(), fformat="unrst", name="PROP", - grid=xtgeo.Grid(), + grid=xtgeo.create_box_grid((2, 2, 2)), date=19991231, ) @@ -390,7 +390,7 @@ def unrst_intehead(self): @property def logihead_array(self): - logihead = np.zeros(128, dtype=np.bool) + logihead = np.zeros(128, dtype=bool) logihead[6] = self.grid.dualporo return logihead diff --git a/tests/test_plot/test_xsection.py b/tests/test_plot/test_xsection.py index c15ef23ed..f03064897 100644 --- a/tests/test_plot/test_xsection.py +++ b/tests/test_plot/test_xsection.py @@ -34,7 +34,7 @@ def test_xsection_init(): def test_simple_plot(tmpdir, show_plot, generate_plot): """Test as simple XSECT plot.""" - mywell = xtgeo.Well(USEFILE4) + mywell = xtgeo.well_from_file(USEFILE4) mysurfaces = [] mysurf = xtgeo.surface_from_file(USEFILE2) @@ -76,8 +76,8 @@ def test_simple_plot(tmpdir, show_plot, generate_plot): def test_simple_plot_with_seismics(tmpdir, show_plot, generate_plot): """Test as simple XSECT plot with seismic backdrop.""" - mywell = xtgeo.Well(USEFILE7) - mycube = xtgeo.Cube(USEFILE6) + mywell = xtgeo.well_from_file(USEFILE7) + mycube = xtgeo.cube_from_file(USEFILE6) mysurfaces = [] mysurf = xtgeo.surface_from_file(USEFILE2) @@ -130,7 +130,7 @@ def test_simple_plot_with_seismics(tmpdir, show_plot, generate_plot): def test_multiple_subplots(tmpdir, show_plot, generate_plot): """Test as simple XSECT plot.""" - mywell = xtgeo.Well(USEFILE4) + mywell = xtgeo.well_from_file(USEFILE4) mysurf = xtgeo.surface_from_file(USEFILE2) myplot = XSection(zmin=1500, zmax=1800, well=mywell, surfaces=[mysurf]) @@ -151,7 +151,7 @@ def test_reek1(tmpdir, generate_plot): wnames = glob.glob(str(USEFILE4)) wnames.sort() for wname in wnames: - mywell = xtgeo.Well(wname) + mywell = xtgeo.well_from_file(wname) mywells.append(mywell) logger.info("Wells are read...") diff --git a/tests/test_surface/test_regular_surface_vs_cube.py b/tests/test_surface/test_regular_surface_vs_cube.py index 7389d8ad5..22e44fe91 100644 --- a/tests/test_surface/test_regular_surface_vs_cube.py +++ b/tests/test_surface/test_regular_surface_vs_cube.py @@ -9,7 +9,6 @@ import xtgeo from xtgeo.common import XTGeoDialog -from xtgeo.cube import Cube xtg = XTGeoDialog() logger = xtg.basiclogger(__name__) @@ -37,7 +36,7 @@ def load_cube_rsgy1(): """Loading test cube (pytest setup fixture)""" logger.info("Load cube RSGY1") - return Cube(RSGY1) + return xtgeo.cube_from_file(RSGY1) def test_get_surface_from_cube(load_cube_rsgy1): @@ -521,7 +520,7 @@ def test_cube_slice_auto4d_data(tmpdir, generate_plot): np.testing.assert_allclose(xs1.values, xs2.values, atol=0.0001) - kube1 = Cube(XCUB1) + kube1 = xtgeo.cube_from_file(XCUB1) kube1.describe() assert xs2.nactive == 10830 @@ -551,7 +550,7 @@ def test_cube_slice_w_ignore_dead_traces_nearest(tmpdir, generate_plot): """Get cube slice nearest aka Auto4D input, with scrambled data with dead traces, various YFLIP cases, ignore dead traces.""" - cube1 = Cube(XCUB2) + cube1 = xtgeo.cube_from_file(XCUB2) surf1 = xtgeo.surface_from_cube(cube1, 1000.1) @@ -604,7 +603,7 @@ def test_cube_slice_w_dead_traces_nearest(tmpdir, generate_plot): """Get cube slice nearest aka Auto4D input, with scrambled data with dead traces, various YFLIP cases, undef at dead traces.""" - cube1 = Cube(XCUB2) + cube1 = xtgeo.cube_from_file(XCUB2) surf1 = xtgeo.surface_from_cube(cube1, 1000.1) @@ -645,7 +644,7 @@ def test_cube_slice_w_ignore_dead_traces_trilinear(tmpdir, generate_plot): """Get cube slice trilinear aka Auto4D input, with scrambled data with dead traces to be ignored, various YFLIP cases.""" - cube1 = Cube(XCUB2) + cube1 = xtgeo.cube_from_file(XCUB2) surf1 = xtgeo.surface_from_cube(cube1, 1000.0) @@ -669,7 +668,7 @@ def test_cube_slice_w_dead_traces_trilinear(tmpdir, generate_plot): """Get cube slice trilinear aka Auto4D input, with scrambled data with dead traces to be ignored, various YFLIP cases.""" - cube1 = Cube(XCUB2) + cube1 = xtgeo.cube_from_file(XCUB2) surf1 = xtgeo.surface_from_cube(cube1, 1000.0) diff --git a/tests/test_surface/test_regular_surface_vs_grd3d.py b/tests/test_surface/test_regular_surface_vs_grd3d.py index 69c843d95..e9a133fef 100644 --- a/tests/test_surface/test_regular_surface_vs_grd3d.py +++ b/tests/test_surface/test_regular_surface_vs_grd3d.py @@ -33,12 +33,12 @@ def test_get_surface_from_grd3d_porosity(tmpdir, generate_plot): surf = xtgeo.surface_from_file(RTOP1) print(surf.values.min(), surf.values.max()) - grd = xtgeo.grid3d.Grid(RGRD1, fformat="egrid") + grd = xtgeo.grid_from_file(RGRD1, fformat="egrid") surf.values = 1700 zsurf = surf.copy() surfr = surf.copy() surf2 = surf.copy() - phi = xtgeo.grid3d.GridProperty(RPROP1, fformat="init", name="PORO", grid=grd) + phi = xtgeo.gridproperty_from_file(RPROP1, fformat="init", name="PORO", grid=grd) # slice grd3d surf.slice_grid3d(grd, phi) @@ -72,9 +72,9 @@ def test_get_surface_from_grd3d_zones(tmpdir, generate_plot): """Sample a surface from a 3D grid, using zones""" surf = xtgeo.surface_from_file(RTOP1) - grd = xtgeo.grid3d.Grid(RGRD2, fformat="roff") + grd = xtgeo.grid_from_file(RGRD2, fformat="roff") surf.values = 1700 - zone = xtgeo.grid3d.GridProperty(RPROP2, fformat="roff", name="Zone", grid=grd) + zone = xtgeo.gridproperty_from_file(RPROP2, fformat="roff", name="Zone", grid=grd) # slice grd3d surf.slice_grid3d(grd, zone, sbuffer=1) @@ -88,8 +88,8 @@ def test_get_surface_from_grd3d_zones(tmpdir, generate_plot): def test_surface_from_grd3d_layer(tmpdir, generate_plot, default_surface): """Create a surface from a 3D grid layer""" - surf = xtgeo.surface.RegularSurface(**default_surface) - grd = xtgeo.grid3d.Grid(RGRD2, fformat="roff") + surf = xtgeo.RegularSurface(**default_surface) + grd = xtgeo.grid_from_file(RGRD2, fformat="roff") surf = xtgeo.surface_from_grid3d(grd) surf.fill() diff --git a/tests/test_surface/test_surface_cube_attrs.py b/tests/test_surface/test_surface_cube_attrs.py index 92066f607..2d91a699f 100644 --- a/tests/test_surface/test_surface_cube_attrs.py +++ b/tests/test_surface/test_surface_cube_attrs.py @@ -29,14 +29,14 @@ def fixture_loadsfile1(): """Fixture for loading a SFILE1""" logger.info("Load seismic file 1") - return xtgeo.Cube(SFILE1) + return xtgeo.cube_from_file(SFILE1) @pytest.fixture(name="loadsfile2") def fixture_loadsfile2(): """Fixture for loading a SFILE2""" logger.info("Load seismic file 2") - return xtgeo.Cube(SFILE2) + return xtgeo.cube_from_file(SFILE2) def test_single_slice_yflip_snapxy_both(loadsfile1): diff --git a/tests/test_surface/test_surfaces.py b/tests/test_surface/test_surfaces.py index 679c87fef..0c9034764 100644 --- a/tests/test_surface/test_surfaces.py +++ b/tests/test_surface/test_surfaces.py @@ -127,7 +127,7 @@ def test_surfaces_apply(constant_map_surfaces): def test_get_surfaces_from_3dgrid(tmpdir): """Create surfaces from a 3D grid.""" - mygrid = xtgeo.Grid(TESTSETG1) + mygrid = xtgeo.grid_from_file(TESTSETG1) surfs = xtgeo.surface.surfaces.surfaces_from_grid(mygrid, rfactor=2) surfs.describe() diff --git a/tests/test_well/test_blockedwell.py b/tests/test_well/test_blockedwell.py index 56ded86dd..1d7852114 100644 --- a/tests/test_well/test_blockedwell.py +++ b/tests/test_well/test_blockedwell.py @@ -4,9 +4,8 @@ from os.path import join import pytest - +import xtgeo from xtgeo.common import XTGeoDialog -from xtgeo.well import BlockedWell xtg = XTGeoDialog() logger = xtg.basiclogger(__name__) @@ -23,7 +22,7 @@ def loadwell1(): """Fixture for loading a well (pytest setup)""" logger.info("Load well 1") - return BlockedWell(wfile) + return xtgeo.blockedwell_from_file(wfile) def test_import(loadwell1): diff --git a/tests/test_well/test_deprecations.py b/tests/test_well/test_deprecations.py index 859fd974f..d976dc677 100644 --- a/tests/test_well/test_deprecations.py +++ b/tests/test_well/test_deprecations.py @@ -36,6 +36,11 @@ def test_init_from_file_warns(any_well_file): Well(any_well_file) +def test_blockedwell_init_from_file_warns(any_well_file): + with pytest.warns(DeprecationWarning, match="from file"): + xtgeo.BlockedWell(any_well_file) + + def test_wells_init_warns(any_well_file): with pytest.warns(DeprecationWarning, match="directly from file"):