From 5e53116eef92e1800fc0950b1268bfef8eabe47d Mon Sep 17 00:00:00 2001 From: mferrera Date: Fri, 19 Jul 2024 13:12:15 +0200 Subject: [PATCH] DEP: Complete xtgeo 4 grid/gridprop deprecations --- src/xtgeo/grid3d/_grid_wellzone.py | 4 - src/xtgeo/grid3d/_gridprop_import_roff.py | 10 - src/xtgeo/grid3d/grid.py | 408 +----------------- src/xtgeo/grid3d/grid_property.py | 295 +------------ tests/test_etc/test_etc_make_avg_maps.py | 12 +- tests/test_etc/test_etc_make_hcpv_maps.py | 10 +- tests/test_grid3d/test_grid.py | 24 +- tests/test_grid3d/test_grid3d_deprecations.py | 91 +--- tests/test_grid3d/test_grid_operations.py | 6 +- tests/test_grid3d/test_grid_property.py | 32 +- tests/test_grid3d/test_grid_property_roff.py | 2 +- tests/test_grid3d/test_grid_vs_poly.py | 8 +- tests/test_opm_integration/test_grid_io.py | 4 +- 13 files changed, 39 insertions(+), 867 deletions(-) diff --git a/src/xtgeo/grid3d/_grid_wellzone.py b/src/xtgeo/grid3d/_grid_wellzone.py index 5715970c6..f8ab872ba 100644 --- a/src/xtgeo/grid3d/_grid_wellzone.py +++ b/src/xtgeo/grid3d/_grid_wellzone.py @@ -23,7 +23,6 @@ def report_zone_mismatch( well: Well | None = None, zonelogname: str = "ZONELOG", zoneprop: GridProperty | None = None, - onelayergrid: Grid | None = None, # redundant; will be computed internally zonelogrange: tuple[int, int] = (0, 9999), zonelogshift: int = 0, depthrange: tuple[int | float, int | float] | None = None, @@ -48,9 +47,6 @@ def report_zone_mismatch( """ self._xtgformat1() - if onelayergrid is not None: - xtg.warndeprecated("Using key 'onelayergrid' is redundant and can be skipped") - if not isinstance(well, Well): raise ValueError("Input well is not a Well() instance") diff --git a/src/xtgeo/grid3d/_gridprop_import_roff.py b/src/xtgeo/grid3d/_gridprop_import_roff.py index 7b9682b2a..f217a6e90 100644 --- a/src/xtgeo/grid3d/_gridprop_import_roff.py +++ b/src/xtgeo/grid3d/_gridprop_import_roff.py @@ -2,7 +2,6 @@ from __future__ import annotations -import warnings from typing import TYPE_CHECKING, Any import numpy as np @@ -24,15 +23,6 @@ def import_roff( grid: Grid | None = None, ) -> dict[str, Any]: """Import ROFF format""" - - if name == "unknown": - warnings.warn( - "Using name='unknown' to select first property in roff file" - " is deprecated, use name=None instead", - DeprecationWarning, - ) - name = None - result: dict[str, Any] = {} roff_param = RoffParameter.from_file(pfile._file, name) result["codes"] = roff_param.xtgeo_codes() diff --git a/src/xtgeo/grid3d/grid.py b/src/xtgeo/grid3d/grid.py index 25f977f28..a5f30c7d7 100644 --- a/src/xtgeo/grid3d/grid.py +++ b/src/xtgeo/grid3d/grid.py @@ -2,13 +2,9 @@ from __future__ import annotations -import functools import json -import pathlib -import warnings from typing import TYPE_CHECKING, Any, Literal, NoReturn -import deprecation import numpy as np import numpy.ma as ma @@ -17,7 +13,6 @@ from xtgeo.common.exceptions import InvalidFileFormatError from xtgeo.common.sys import generic_hash from xtgeo.common.types import Dimensions -from xtgeo.common.version import __version__ from xtgeo.io._file import FileFormat, FileWrapper from . import ( @@ -28,7 +23,6 @@ _grid_hybrid, _grid_import, _grid_import_ecl, - _grid_import_xtgcpgeom, _grid_refine, _grid_roxapi, _grid_wellzone, @@ -38,7 +32,8 @@ from .grid_properties import GridProperties if TYPE_CHECKING: - from collections.abc import Callable, Hashable, Sequence + import pathlib + from collections.abc import Callable, Hashable import pandas as pd @@ -150,7 +145,6 @@ def grid_from_roxar( project: str, gname: str, realisation: int = 0, - dimensions_only: bool | None = None, info: bool = False, ) -> Grid: """Read a 3D grid inside a RMS project and return a Grid() instance. @@ -173,15 +167,6 @@ def grid_from_roxar( mygrid = xtgeo.grid_from_roxar(project, "REEK_SIM") """ - - if dimensions_only is not None: - warnings.warn( - "Argument 'dimension_only' is redundant and has no effect " - "It will no longer be supported in xtgeo version 4.0 and " - "can safely be removed.", - DeprecationWarning, - ) - return Grid(**_grid_roxapi.import_grid_roxapi(project, gname, realisation, info)) @@ -293,55 +278,6 @@ def grid_from_cube( IJKRange: tuple[int, int, int, int, int, int] -def _allow_deprecated_init(func: Callable) -> Callable: - # This decorator is here to maintain backwards compatibility in the construction - # of RegularSurface and should be deleted once the deprecation period has expired, - # the construction will then follow the new pattern. - @functools.wraps(func) - def wrapper(self, *args, **kwargs): # type: ignore - # Checking if we are doing an initialization - # from file and raise a deprecation warning if - # we are. - if "gfile" in kwargs or ( - len(args) >= 1 and isinstance(args[0], (str, pathlib.Path, FileWrapper)) - ): - warnings.warn( - "Initializing directly from file name is deprecated and will be " - "removed in xtgeo version 4.0. Use: " - "mygrid = xtgeo.grid_from_file('some_name.roff') instead", - DeprecationWarning, - ) - - def constructor(**kwargs): # type: ignore - func(self, **kwargs) - return self - - _handle_import(constructor, *args, **kwargs) - return None - - # Check if we are doing default value init - if len(args) == 0 and len(kwargs) == 0: - warnings.warn( - "Initializing default box grid is deprecated and will be " - "removed in xtgeo version 4.0. Use: " - "mygrid = xtgeo.create_box_grid() or, alternatively," - "directly from file with mygrid = xtgeo.grid_from_file().", - DeprecationWarning, - ) - kwargs = _grid_etc1.create_box( - dimension=(4, 3, 5), - origin=(10.0, 20.0, 1000.0), - oricenter=False, - increment=(100, 150, 5), - rotation=30.0, - flip=1, - ) - return func(self, **kwargs) - return func(self, *args, **kwargs) - - return wrapper - - class Grid(_Grid3D): """Class for a 3D grid corner point geometry in XTGeo. @@ -380,7 +316,6 @@ class Grid(_Grid3D): """ - @_allow_deprecated_init def __init__( self, coordsv: np.ndarray, @@ -432,39 +367,6 @@ def __init__( super().__init__(*actnumsv.shape) - self._reset( - coordsv=coordsv, - zcornsv=zcornsv, - actnumsv=actnumsv, - dualporo=dualporo, - dualperm=dualperm, - subgrids=subgrids, - units=units, - filesrc=filesrc, - props=props, - name=name, - roxgrid=roxgrid, - roxindexer=roxindexer, - ) - - def _reset( - self, - coordsv: np.ndarray, - zcornsv: np.ndarray, - actnumsv: np.ndarray, - dualporo: bool = False, - dualperm: bool = False, - subgrids: dict[str, range | list[int]] | None = None, - units: Units | None = None, - filesrc: pathlib.Path | str | None = None, - props: GridProperties | None = None, - name: str | None = None, - roxgrid: Any | None = None, - roxindexer: Any | None = None, - ) -> None: - """This function only serves to allow deprecated initialization.""" - # TODO: Remove once implicit initialization such as Grid().from_file() - # is removed self._xtgformat = 2 self._ncol = actnumsv.shape[0] self._nrow = actnumsv.shape[1] @@ -792,48 +694,6 @@ def generate_hash( # Create/import/export # ================================================================================== - @deprecation.deprecated( - deprecated_in="2.16", - removed_in="4.0", - current_version=__version__, - details="Use xtgeo.create_box_grid() instead", - ) - def create_box( - self, - dimension: tuple[int, int, int] = (10, 12, 6), - origin: tuple[float, float, float] = (10.0, 20.0, 1000.0), - oricenter: bool = False, - increment: tuple[int, int, int] = (100, 150, 5), - rotation: float = 30.0, - flip: Literal[1, -1] = 1, - ) -> None: - """Create a rectangular 'shoebox' grid from spec. - - Args: - dimension (tuple of int): A tuple of (NCOL, NROW, NLAY) - origin (tuple of float): Startpoint of grid (x, y, z) - oricenter (bool): If False, startpoint is node, if True, use cell center - increment (tuple of float): Grid increments (xinc, yinc, zinc) - rotation (float): Roations in degrees, anticlock from X axis. - flip (int): If +1, grid origin is lower left and left-handed; - if -1, origin is upper left and right-handed (row flip). - - Returns: - Instance is updated (previous instance content will be erased) - - .. versionadded:: 2.1 - """ - kwargs = _grid_etc1.create_box( - dimension=dimension, - origin=origin, - oricenter=oricenter, - increment=increment, - rotation=rotation, - flip=flip, - ) - - self._reset(**kwargs) - def to_file(self, gfile: FileLike, fformat: str = "roff") -> None: """Export grid geometry to file, various vendor formats. @@ -982,176 +842,6 @@ def to_roxar( self, project, gname, realisation, info=info, method=method ) - @deprecation.deprecated( - deprecated_in="2.16", - removed_in="4.0", - current_version=__version__, - details="Use xtgeo.grid_from_file() instead", - ) - def from_file( - self, - gfile: FileLike, - fformat: str | None = None, - **kwargs: Any, - ) -> Grid: - """Import grid geometry from file, and makes an instance of this class. - - If file extension is missing, then the extension will guess the fformat - key, e.g. fformat egrid will be guessed if ".EGRID". The "eclipserun" - will try to input INIT and UNRST file in addition the grid in "one go". - - Arguments: - gfile (str or Path): File name to be imported. If fformat="eclipse_run" - then a fileroot name shall be input here, see example below. - fformat (str): File format egrid/roff/grdecl/bgrdecl/eclipserun/xtgcpgeom - (None is default and means "guess") - initprops (str list): Optional, and only applicable for file format - "eclipserun". Provide a list the names of the properties here. A - special value "all" can be get all properties found in the INIT file - restartprops (str list): Optional, see initprops - restartdates (int list): Optional, required if restartprops - ijkrange (list-like): Optional, only applicable for hdf files, see - :meth:`Grid.from_hdf`. - zerobased (bool): Optional, only applicable for hdf files, see - :meth:`Grid.from_hdf`. - mmap (bool): Optional, only applicable for xtgf files, see - :meth:`Grid.from_xtgf`. - - Example:: - - >>> xg = Grid() - >>> xg.from_file(reek_dir + "/REEK.EGRID", fformat="egrid") - Grid ... filesrc='.../REEK.EGRID' - - Example using "eclipserun":: - - >>> mycase = "REEK" # meaning REEK.EGRID, REEK.INIT, REEK.UNRST - >>> xg = Grid() - >>> xg.from_file( - ... reek_dir + "/" + mycase, - ... fformat="eclipserun", - ... initprops="all", - ... ) - Grid ... filesrc='.../REEK.EGRID' - - Raises: - OSError: if file is not found etc - """ - - def constructor(*args, **kwargs): # type: ignore - self._reset(*args, **kwargs) - return self - - _handle_import(constructor, gfile, fformat, **kwargs) - return self - - @deprecation.deprecated( - deprecated_in="2.16", - removed_in="4.0", - current_version=__version__, - details="Use xtgeo.grid_from_file() instead", - ) - def from_hdf( - self, - gfile: FileLike, - ijkrange: Sequence[int] | None = None, - zerobased: bool = False, - ) -> None: - """Import grid geometry from HDF5 file (experimental!). - - Args: - gfile (str): Name of output file - ijkrange (list-like): Partial read, e.g. (1, 20, 1, 30, 1, 3) as - (i1, i2, j1, j2, k1, k2). Numbering scheme depends on `zerobased`, - where default is `eclipse-like` i.e. first cell is 1. Numbering - is inclusive for both ends. If ijkrange exceeds original range, - an Exception is raised. Using existing boundaries can be defaulted - by "min" and "max", e.g. (1, 20, 5, 10, "min", "max") - zerobased (bool): If True index in ijkrange is zero based. - - Raises: - ValueError: The ijkrange spesification exceeds boundaries. - ValueError: The ijkrange list must have 6 elements - - Example:: - - >>> xg = create_box_grid((20,20,5)) - >>> filename = xg.to_hdf(outdir + "/myfile_grid.h5") - >>> xg.from_hdf(filename, ijkrange=(1, 10, 10, 15, 1, 4)) - """ - gfile = FileWrapper(gfile, mode="wb", obj=self) - - kwargs = _grid_import_xtgcpgeom.import_hdf5_cpgeom( - gfile, ijkrange=ijkrange, zerobased=zerobased - ) - self._reset(**kwargs) - - @deprecation.deprecated( - deprecated_in="2.16", - removed_in="4.0", - current_version=__version__, - details="Use xtgeo.grid_from_file() instead", - ) - def from_xtgf(self, gfile: FileLike, mmap: bool = False) -> None: - """Import grid geometry from native xtgeo file format (experimental!). - - Args: - gfile (str): Name of output file - mmap (bool): If true, reading with memory mapping is active - - Example:: - - >>> xg = create_box_grid((5,5,5)) - >>> filename = xg.to_xtgf(outdir + "/myfile_grid.xtg") - >>> xg.from_xtgf(filename) - """ - gfile = FileWrapper(gfile, mode="wb", obj=self) - - kwargs = _grid_import_xtgcpgeom.import_xtgcpgeom(gfile, mmap) - self._reset(**kwargs) - - @deprecation.deprecated( - deprecated_in="2.16", - removed_in="4.0", - current_version=__version__, - details="Use xtgeo.grid_from_roxar() instead", - ) - def from_roxar( - self, - projectname: str, - gname: str, - realisation: int = 0, - dimensions_only: bool | None = None, - info: bool = False, - ) -> None: - """Import grid model geometry from RMS project, and makes an instance. - - Args: - projectname (str): Name of RMS project - gname (str): Name of grid model - realisation (int): Realisation number. - dimensions_only (bool): If True, only the ncol, nrow, nlay will - read. The actual grid geometry will remain empty (None). This - will be much faster of only grid size info is needed, e.g. - for initalising a grid property. - info (bool): If True, various info will printed to screen. This - info will depend on version of ROXAPI, and is mainly a - developer/debugger feature. Default is False. - - - """ - - if dimensions_only is not None: - warnings.warn( - "Argument 'dimension_only' is redundant and has no effect " - "It will no longer be supported in xtgeo version 4.0 and " - "can safely be removed.", - DeprecationWarning, - ) - - kwargs = _grid_roxapi.import_grid_roxapi(projectname, gname, realisation, info) - self._reset(**kwargs) - def convert_units(self, units: Units) -> None: """ Convert the units of the grid. @@ -1302,19 +992,6 @@ def get_dataframe( doubleformat=doubleformat, ) - @deprecation.deprecated( - deprecated_in="2.16", - removed_in="4.0", - current_version=__version__, - details="Method dataframe is deprecated, use get_dataframe instead.", - ) - def dataframe(self, *args: Any, **kwargs: Any) -> pd.DataFrame: - """ - Returns: - A Pandas dataframe - """ - return self.get_dataframe(*args, **kwargs) - def get_vtk_esg_geometry_data( self, ) -> tuple[ @@ -1678,19 +1355,6 @@ def get_dualactnum_indices( actnumvm[(actnumv == 2) | (actnumv == 0)] = 0 return np.flatnonzero(actnumvm) - @deprecation.deprecated( - deprecated_in="2.16", - removed_in="4.0", - current_version=__version__, - details="Use xtgeo.Grid().gridprops instead", - ) - def get_gridproperties(self) -> GridProperties: - """Return the :obj:`GridProperties` instance attached to the grid. - - See also the :meth:`gridprops` property - """ - return self._props - def get_prop_by_name(self, name: str) -> GridProperty | None: """Gets a property object by name lookup, return None if not present.""" @@ -1710,7 +1374,6 @@ def get_actnum( self, name: str = "ACTNUM", asmasked: bool = False, - mask: bool | None = None, dual: bool = False, ) -> GridProperty: """Return an ACTNUM GridProperty object. @@ -1719,7 +1382,6 @@ def get_actnum( name (str): name of property in the XTGeo GridProperty object. asmasked (bool): Actnum is returned with all cells shown as default. Use asmasked=True to make 0 entries masked. - mask (bool): Deprecated, use asmasked instead! dual (bool): If True, and the grid is a dualporo/perm grid, an extended ACTNUM is applied (numbers 0..3) @@ -1733,13 +1395,6 @@ def get_actnum( .. versionchanged:: 2.6 Added ``dual`` keyword """ - if mask is not None: - xtg.warndeprecated( - "The mask option is deprecated," - "and will be removed in version 4.0. Use asmasked instead." - ) - asmasked = self._evaluate_mask(mask) - if dual and self._dualactnum: act = self._dualactnum.copy() else: @@ -1795,7 +1450,6 @@ def get_dz( name: str = "dZ", flip: bool = True, asmasked: bool = True, - mask: bool | None = None, metric: METRIC = "z projection", ) -> GridProperty: """Return the dZ as GridProperty object. @@ -1809,7 +1463,6 @@ def get_dz( flip (bool): Use False for Petrel grids were Z is negative down (experimental) asmasked (bool): True if only for active cells, False for all cells - mask (bool): Deprecated, use asmasked instead! metric (str): One of the following metrics: * "euclid": sqrt(dx^2 + dy^2 + dz^2) * "horizontal": sqrt(dx^2 + dy^2) @@ -1822,13 +1475,6 @@ def get_dz( Returns: A XTGeo GridProperty object dZ """ - if mask is not None: - xtg.warndeprecated( - "The mask option is deprecated," - "and will be removed in version 4.0. Use asmasked instead." - ) - asmasked = self._evaluate_mask(mask) - return _grid_etc1.get_dz( self, name=name, @@ -1897,35 +1543,6 @@ def get_dy( """ return _grid_etc1.get_dy(self, name=name, asmasked=asmasked, metric=metric) - @deprecation.deprecated( - deprecated_in="3.0", - removed_in="4.0", - current_version=__version__, - details="Use xtgeo.Grid.get_dx() and/or xtgeo.Grid.get_dy() instead.", - ) - def get_dxdy( - self, - names: tuple[str, str] = ("dX", "dY"), - asmasked: bool = False, - ) -> tuple[GridProperty, GridProperty]: - """Return the dX and dY as GridProperty object. - - The values lengths are projected to a constant Z. - - Args: - name (tuple): names of properties - asmasked (bool). If True, make a np.ma array where inactive cells - are masked. - - Returns: - Two XTGeo GridProperty objects (dx, dy). - XTGeo GridProperty objects containing dy. - """ - return ( - self.get_dx(name=names[0], asmasked=asmasked), - self.get_dy(name=names[1], asmasked=asmasked), - ) - def get_cell_volume( self, ijk: tuple[int, int, int] = (1, 1, 1), @@ -2038,7 +1655,6 @@ def get_ijk( self, names: tuple[str, str, str] = ("IX", "JY", "KZ"), asmasked: bool = True, - mask: bool | None = None, zerobased: bool = False, ) -> tuple[GridProperty, GridProperty, GridProperty]: """Returns 3 xtgeo.grid3d.GridProperty objects: I counter, J counter, K counter. @@ -2046,16 +1662,8 @@ def get_ijk( Args: names: a 3 x tuple of names per property (default IX, JY, KZ). asmasked: If True, UNDEF cells are masked, default is True - mask (bool): Deprecated, use asmasked instead! zerobased: If True, counter start from 0, otherwise 1 (default=1). """ - if mask is not None: - xtg.warndeprecated( - "The mask option is deprecated," - "and will be removed in version 4.0. Use asmasked instead." - ) - asmasked = self._evaluate_mask(mask) - ixc, jyc, kzc = _grid_etc1.get_ijk( self, names=names, asmasked=asmasked, zerobased=zerobased ) @@ -2108,7 +1716,6 @@ def get_xyz( self, names: tuple[str, str, str] = ("X_UTME", "Y_UTMN", "Z_TVDSS"), asmasked: bool = True, - mask: bool | None = None, ) -> tuple[ GridProperty, GridProperty, @@ -2125,15 +1732,7 @@ def get_xyz( names: a 3 x tuple of names per property (default is X_UTME, Y_UTMN, Z_TVDSS). asmasked: If True, then inactive cells is masked (numpy.ma). - mask (bool): Deprecated, use asmasked instead! """ - if mask is not None: - xtg.warndeprecated( - "The mask option is deprecated," - "and will be removed in version 4.0. Use asmasked instead." - ) - asmasked = self._evaluate_mask(mask) - return _grid_etc1.get_xyz(self, names=tuple(names), asmasked=asmasked) def get_xyz_cell_corners( @@ -2650,7 +2249,6 @@ def report_zone_mismatch( well: Well | None = None, zonelogname: str = "ZONELOG", zoneprop: GridProperty | None = None, - onelayergrid: tuple | None = None, zonelogrange: tuple[int, int] = (0, 9999), zonelogshift: int = 0, depthrange: tuple | None = None, @@ -2683,7 +2281,6 @@ def report_zone_mismatch( zoneprop (GridProperty): Grid property instance to use for zonation zonelogrange (tuple): zone log range, from - to (inclusive) - onelayergrid (Grid): Redundant from version 2.8, please skip! zonelogshift (int): Deviation (numerical shift) between grid and zonelog, e.g. if Zone property starts with 1 and this corresponds to a zonelog index of 3 in the well, the shift shall be -2. @@ -2738,7 +2335,6 @@ def report_zone_mismatch( well=well, zonelogname=zonelogname, zoneprop=zoneprop, - onelayergrid=onelayergrid, zonelogrange=zonelogrange, zonelogshift=zonelogshift, depthrange=depthrange, diff --git a/src/xtgeo/grid3d/grid_property.py b/src/xtgeo/grid3d/grid_property.py index 3d1ae69b2..ac873e9b1 100644 --- a/src/xtgeo/grid3d/grid_property.py +++ b/src/xtgeo/grid3d/grid_property.py @@ -3,12 +3,9 @@ import copy import functools import hashlib -import pathlib -import warnings from types import FunctionType from typing import TYPE_CHECKING, Any, Literal -import deprecation import numpy as np import xtgeo @@ -16,7 +13,6 @@ from xtgeo.common.constants import UNDEF, UNDEF_INT, UNDEF_INT_LIMIT, UNDEF_LIMIT from xtgeo.common.exceptions import InvalidFileFormatError from xtgeo.common.types import Dimensions -from xtgeo.common.version import __version__ from xtgeo.io._file import FileFormat, FileWrapper from xtgeo.metadata.metadata import MetaDataCPProperty @@ -207,66 +203,6 @@ def gridproperty_from_roxar( ) -def _allow_deprecated_init(func: Callable) -> Callable: - # This decorator is here to maintain backwards compatibility in the construction - # of GridProperty and should be deleted once the deprecation period has expired, - # the construction will then follow the new pattern. - @functools.wraps(func) - def wrapper(self: GridProperty, *args: Any, **kwargs: Any) -> Callable: - # Check if dummy values are to be used - if ( - all(param not in kwargs for param in ["values", "ncol", "nrow", "nlay"]) - and len(args) == 0 - ): - warnings.warn( - "Default initialization of GridProperty without values and dimension " - "is deprecated and will be removed in xtgeo version 4.0", - DeprecationWarning, - ) - return func( - self, - *args, - ncol=4, - nrow=3, - nlay=5, - values=_gridprop_value_init.gridproperty_dummy_values( - kwargs.get("discrete", False) - ), - **kwargs, - ) - - # Checking if we are doing an initialization - # from file and raise a deprecation warning if - # we are. - if "pfile" in kwargs or ( - len(args) >= 1 and isinstance(args[0], (str, pathlib.Path, FileWrapper)) - ): - pfile = kwargs.get("pfile", args[0]) - warnings.warn( - "Initializing directly from file name is deprecated and will be " - "removed in xtgeo version 4.0. Use: " - "myprop = xtgeo.gridproperty_from_file('some_name.roff') instead", - DeprecationWarning, - ) - fformat = kwargs.get("fformat", None) - mfile = FileWrapper(pfile) - fmt = mfile.fileformat(fformat) - - if "pfile" in kwargs: - del kwargs["pfile"] - if "fformat" in kwargs: - del kwargs["fformat"] - if len(args) >= 1 and isinstance(args[0], (str, pathlib.Path, FileWrapper)): - args = args[min(len(args), 2) :] - - kwargs = _data_reader_factory(fmt)(mfile, *args, **kwargs) - kwargs["filesrc"] = mfile.file - return func(self, **kwargs) - return func(self, *args, **kwargs) - - return wrapper - - class GridProperty(_Grid3D): """ Class for a single 3D grid property, e.g porosity or facies. @@ -294,7 +230,6 @@ class GridProperty(_Grid3D): """ - @_allow_deprecated_init def __init__( self, gridlike: Grid | GridProperty | None = None, @@ -370,103 +305,6 @@ def __init__( # or from existing GridProperty instance: myprop2 = GridProperty(myprop, values=99, discrete=False) # based on myprop - """ - super().__init__(ncol or 4, nrow or 3, nlay or 5) - self._reset( - gridlike, - ncol, - nrow, - nlay, - name, - discrete, - date, - grid, - linkgeometry, - fracture, - codes, - dualporo, - dualperm, - roxar_dtype, - values, - roxorigin, - filesrc, - ) - - def _reset( - self, - gridlike: Grid | GridProperty | None = None, - ncol: int | None = None, - nrow: int | None = None, - nlay: int | None = None, - name: str = "unknown", - discrete: bool = False, - date: str | None = None, - grid: Grid | None = None, - linkgeometry: bool = True, - fracture: bool = False, - codes: dict[int, str] | None = None, - dualporo: bool = False, - dualperm: bool = False, - roxar_dtype: Roxar_DType | None = None, - values: np.ndarray | float | int | None = None, - roxorigin: bool = False, - filesrc: str | None = None, - ) -> None: - """ - Instantiating. - - Args: - gridlike: Grid or GridProperty instance, or leave blank. - ncol: Number of columns (nx). Defaults to 4. - nrow: Number of rows (ny). Defaults to 3. - nlay: Number of layers (nz). Defaults to 5. - name: Name of property. Defaults to "unknown". - discrete: True or False. Defaults to False. - date: Date on YYYYMMDD form. - grid: Attached Grid object. - linkgeometry: If True, establish a link between GridProperty - and Grid. Defaults to True. - fracture: True if fracture option (relevant for flow simulator data). - Defaults to False. - codes: Codes in case a discrete property e.g. {1: "Sand", 4: "Shale"}. - dualporo: True if dual porosity system. Defaults to False. - dualperm: True if dual porosity and dual permeability system. - Defaults to False. - roxar_dtype: Specify Roxar datatype e.g. np.uint8. - values: Values to apply. - roxorigin: True if the object comes from Roxar API. Defaults to False. - filesrc: Where the file came from. - - Raises: - RuntimeError: If something goes wrong (e.g. file not found). - - Examples:: - - import xtgeo - myprop = xtgeo.gridproperty_from_file("emerald.roff", name="PORO") - - # or - - values = np.ma.ones((12, 17, 10), dtype=np.float64), - myprop = GridProperty(ncol=12, nrow=17, nlay=10, - values=values, discrete=False, - name="MyValue") - - # or create properties from a Grid() instance - - mygrid = xtgeo.grid_from_file("grid.roff") - myprop1 = GridProperty(mygrid, name="PORO") - myprop2 = GridProperty(mygrid, name="FACIES", discrete=True, values=1, - linkgeometry=True) # alternative 1 - myprop2.geometry = mygrid # alternative 2 to link grid geometry to property - - # from Grid instance: - grd = xtgeo.grid_from_file("somefile_grid_file") - myprop = GridProperty(grd, values=99, discrete=True) # based on grd - - # or from existing GridProperty instance: - myprop2 = GridProperty(myprop, values=99, discrete=False) # based on myprop - """ super().__init__(ncol or 4, nrow or 3, nlay or 5) @@ -777,27 +615,6 @@ def roxorigin(self, val: bool) -> None: raise ValueError("Input to roxorigin must be True or False") self._roxorigin = val - @property - @deprecation.deprecated( - deprecated_in="3.6", - removed_in="4.0", - current_version=__version__, - details="Use gridprop.values instead", - ) - def values3d(self) -> np.ma.MaskedArray: - """DEPRECATED: use values instead (kept for backwards compatibility).""" - return self._values - - @values3d.setter - @deprecation.deprecated( - deprecated_in="3.6", - removed_in="4.0", - current_version=__version__, - details="Use gridprop.values instead", - ) - def values3d(self, values: np.ma.MaskedArray) -> None: - self.values = values - @property def values1d(self) -> np.ma.MaskedArray: """Get a masked 1D array view of values.""" @@ -944,71 +761,6 @@ def ensure_correct_values( # Import and export # ================================================================================== - @deprecation.deprecated( - deprecated_in="2.16", - removed_in="4.0", - current_version=__version__, - details="Use xtgeo.gridproperty_from_file() instead", - ) - def from_file( - self, - filelike: FileLike, - fformat: str | None = None, - **kwargs: Any, - ) -> GridProperty: - """ - Import grid property from file, and makes an instance of this class. - - Note that the the property may be linked to its geometrical grid, - through the ``grid=`` option. Sometimes this is required, for instance - for most Eclipse input. - - Args: - filelike: Name of file to be imported - fformat: File format to be used (roff/init/unrst/grdecl). - Defaults to None and tries to infer from file extension. - name: Name of property to import - date: For restart files, date in YYYYMMDD format. Also - the YYYY-MM-DD form is allowed (string), and for Eclipse, - mnemonics like 'first', 'last' is also allowed. - grid: Grid object for checks. Optional for ROFF, required for Eclipse). - gridlink: If True, and grid is not None, a link from the grid - instance to the property is made. If False, no such link is made. - Avoiding gridlink is recommended when running statistics of multiple - realisations of a property. - fracture: Only applicable for DUAL POROSITY systems. If True - then the fracture property is read. If False then the matrix - property is read. Names will be appended with "M" or "F" - ijrange: A list of 4 number: (i1, i2, j1, j2) for subrange - of cells to read. Only applicable for xtgcpprop format. - zerobased: Input if cells counts are zero- or one-based in - ijrange. Only applicable for xtgcpprop format. - - Returns: - A GridProperty instance. - - Examples:: - - import xtgeo - gprop = xtgeo.gridproperty_from_file("somefile.roff", fformat="roff") - - # or - - mygrid = xtgeo.grid_from_file("ECL.EGRID") - pressure_1 = xtgeo.gridproperty_from_file( - "ECL.UNRST", name="PRESSURE", date="first", grid=mygrid - ) - - .. versionchanged:: 2.8 Added gridlink option, default is True - - """ - pfile = FileWrapper(filelike) - fmt = pfile.fileformat(fformat) - kwargs = _data_reader_factory(fmt)(pfile, **kwargs) - kwargs["filesrc"] = pfile.file - self._reset(**kwargs) - return self - @classmethod def _read_file( cls, @@ -1074,43 +826,6 @@ def to_file( fmt=fmt, ) - @deprecation.deprecated( - deprecated_in="2.16", - removed_in="4.0", - current_version=__version__, - details="Use xtgeo.gridproperty_from_roxar() instead", - ) - def from_roxar( - self, - projectname: str, - gridname: str, - propertyname: str, - realisation: int = 0, - faciescodes: bool = False, - ) -> None: - """ - Import grid model property from RMS project, and makes an instance. - - Args: - projectname: Name of RMS project. Use 'project' if inside RMS. - gridname: Name of grid model. - propertyname: Name of grid property. - realisation: Realisation number. Default is 0 (the first). - faciescodes: If a Roxar property is of the special ``body_facies`` - type (e.g. result from a channel facies object modelling), the - default is to get the body code values. If faciescodes is True, - the facies code values will be read instead. For other roxar properties - this key is not relevant. - - .. versionadded:: 2.12 Key `faciescodes` was added - - """ - self._reset( - **_gridprop_roxapi.import_prop_roxapi( - projectname, gridname, propertyname, realisation, faciescodes - ) - ) - @classmethod def _read_roxar( cls, @@ -1263,7 +978,6 @@ def get_actnum( self, name: str = "ACTNUM", asmasked: bool = False, - mask: bool | None = None, ) -> GridProperty: """ Return an ACTNUM GridProperty object. @@ -1277,7 +991,6 @@ def get_actnum( Default is "ACTNUM". asmasked: Default is False, so that actnum is returned with all cells shown. Use asmasked=True to make 0 entries masked. - mask: Deprecated, use asmasked instead! Returns: The ACTNUM GridProperty object. @@ -1288,13 +1001,6 @@ def get_actnum( print('{}% cells are active'.format(act.values.mean() * 100)) """ - if mask is not None: - xtg.warndeprecated( - "The mask option is deprecated," - "and will be removed in version 4.0. Use asmasked instead." - ) - asmasked = super()._evaluate_mask(mask) - act = GridProperty( ncol=self._ncol, nrow=self._nrow, nlay=self._nlay, name=name, discrete=True ) @@ -1379,6 +1085,7 @@ def copy(self, newname: str | None = None) -> GridProperty: """ if newname is None: newname = self.name + assert newname is not None xprop = GridProperty( ncol=self._ncol, diff --git a/tests/test_etc/test_etc_make_avg_maps.py b/tests/test_etc/test_etc_make_avg_maps.py index 333fd40ab..13d0bb733 100644 --- a/tests/test_etc/test_etc_make_avg_maps.py +++ b/tests/test_etc/test_etc_make_avg_maps.py @@ -35,14 +35,14 @@ def test_avg02(tmp_path, generate_plot, testdata_path): actnum = grd.get_actnum() # convert from masked numpy to ordinary - xcuse = np.copy(xc.values3d) - ycuse = np.copy(yc.values3d) - dzuse = np.copy(dz.values3d) - pouse = np.copy(po.values3d) + xcuse = np.copy(xc.values) + ycuse = np.copy(yc.values) + dzuse = np.copy(dz.values) + pouse = np.copy(po.values) # dz must be zero for undef cells - dzuse[actnum.values3d < 0.5] = 0.0 - pouse[actnum.values3d < 0.5] = 0.0 + dzuse[actnum.values < 0.5] = 0.0 + pouse[actnum.values < 0.5] = 0.0 # make a map... estimate from xc and yc zuse = np.ones((xcuse.shape)) diff --git a/tests/test_etc/test_etc_make_hcpv_maps.py b/tests/test_etc/test_etc_make_hcpv_maps.py index 7b8c7ddbe..9e475b71d 100644 --- a/tests/test_etc/test_etc_make_hcpv_maps.py +++ b/tests/test_etc/test_etc_make_hcpv_maps.py @@ -33,12 +33,12 @@ def test_hcpvfz1(tmp_path, generate_plot, testdata_path): dz = grd.get_dz(asmasked=False) xc, yc, _zc = grd.get_xyz(asmasked=False) - xcv = ma.filled(xc.values3d) - ycv = ma.filled(yc.values3d) - dzv = ma.filled(dz.values3d) + xcv = ma.filled(xc.values) + ycv = ma.filled(yc.values) + dzv = ma.filled(dz.values) - hcpfz = ma.filled(st.values3d, fill_value=0.0) - tov = ma.filled(to.values3d, fill_value=10) + hcpfz = ma.filled(st.values, fill_value=0.0) + tov = ma.filled(to.values, fill_value=10) tov[tov < 1.0e-32] = 1.0e-32 hcpfz = hcpfz * dzv / tov diff --git a/tests/test_grid3d/test_grid.py b/tests/test_grid3d/test_grid.py index eccffbb87..7844f632b 100644 --- a/tests/test_grid3d/test_grid.py +++ b/tests/test_grid3d/test_grid.py @@ -60,11 +60,6 @@ def test_create_shoebox(tmp_path): grd = xtgeo.create_box_grid((4, 3, 5)) grd.to_file(tmp_path / "shoebox_default.roff") - with pytest.warns(DeprecationWarning, match="create_box is deprecated"): - grd = Grid() - grd.create_box((4, 3, 5)) - grd.to_file(tmp_path / "shoebox_default2.roff") - grd = xtgeo.create_box_grid((2, 3, 4), flip=-1) grd.to_file(tmp_path / "shoebox_default_flipped.roff") @@ -130,8 +125,8 @@ def test_emerald_grid_values(emerald_grid): assert mydz == pytest.approx(2.761, abs=0.001), "Grid DZ Emerald" dxv, dyv = (emerald_grid.get_dx(), emerald_grid.get_dy()) - mydx = float(dxv.values3d[31:32, 72:73, 0:1]) - mydy = float(dyv.values3d[31:32, 72:73, 0:1]) + mydx = float(dxv.values[31:32, 72:73, 0:1]) + mydy = float(dyv.values[31:32, 72:73, 0:1]) assert mydx == pytest.approx(118.51, abs=0.01), "Grid DX Emerald" assert mydy == pytest.approx(141.26, abs=0.01), "Grid DY Emerald" @@ -624,12 +619,6 @@ def test_grid_get_dz(dimension, dx, dy, dz): assert np.isclose(grd.get_dz(asmasked=False).values[0, 0, 0], dz, atol=0.01) -@given(xtgeo_grids) -def test_get_dxdy_is_get_dx_and_dy(grid): - assert np.all(grid.get_dxdy(asmasked=True)[0].values == grid.get_dx().values) - assert np.all(grid.get_dxdy(asmasked=True)[1].values == grid.get_dy().values) - - def test_benchmark_grid_get_dz(benchmark): grd = xtgeo.create_box_grid(dimension=(100, 100, 100)) @@ -639,15 +628,6 @@ def run(): benchmark(run) -def test_benchmark_grid_get_dxdy(benchmark): - grd = xtgeo.create_box_grid(dimension=(100, 100, 100)) - - def run(): - grd.get_dxdy() - - benchmark(run) - - def test_grid_get_dxdydz_zero_size(): grd = xtgeo.create_box_grid(dimension=(0, 0, 0)) diff --git a/tests/test_grid3d/test_grid3d_deprecations.py b/tests/test_grid3d/test_grid3d_deprecations.py index 9077c1d84..938667859 100644 --- a/tests/test_grid3d/test_grid3d_deprecations.py +++ b/tests/test_grid3d/test_grid3d_deprecations.py @@ -1,16 +1,11 @@ -import io import pathlib -import numpy as np import pytest import xtgeo -from hypothesis import given from packaging import version -from xtgeo import GridProperties, GridProperty +from xtgeo import GridProperties from xtgeo.common.version import __version__ as xtgeo_version -from .gridprop_generator import grid_properties - @pytest.fixture(name="any_grid") def fixture_any_grid(): @@ -48,70 +43,6 @@ def test_gridproperties_init_deprecations(any_gridprop): GridProperties(nlay=10, props=[any_gridprop]) -def test_grid_from_file_warns(tmp_path, any_grid): - if version.parse(xtgeo_version) < version.parse("2.16"): - pytest.skip() - - any_grid.to_file(tmp_path / "grid.roff", fformat="roff") - - with pytest.warns(DeprecationWarning, match="from_file is deprecated"): - any_grid.from_file(tmp_path / "grid.roff", fformat="roff") - - -def test_grid_from_hdf_warns(tmp_path, any_grid): - if version.parse(xtgeo_version) < version.parse("2.16"): - pytest.skip() - - any_grid.to_hdf(tmp_path / "grid.hdf") - - with pytest.warns(DeprecationWarning, match="from_hdf is deprecated"): - any_grid.from_hdf(tmp_path / "grid.hdf") - - -def test_grid_from_xtgf_warns(tmp_path, any_grid): - if version.parse(xtgeo_version) < version.parse("2.16"): - pytest.skip() - - any_grid.to_xtgf(tmp_path / "grid.xtg") - - with pytest.warns(DeprecationWarning, match="from_xtgf is deprecated"): - any_grid.from_xtgf(tmp_path / "grid.xtg") - - -def test_grid_mask_warns(any_grid): - if version.parse(xtgeo_version) >= version.parse("4.0"): - pytest.fail(reason="mask option should be removed") - with pytest.warns(DeprecationWarning, match="mask"): - any_grid.get_actnum(mask=True) - - with pytest.warns(DeprecationWarning, match="mask"): - any_grid.get_ijk(mask=True) - - with pytest.warns(DeprecationWarning, match="mask"): - any_grid.get_xyz(mask=True) - - -@given(grid_properties()) -def test_unknown_name_deprecate(gridprop): - buf = io.BytesIO() - gridprop.to_file(buf, fformat="roff") - - buf.seek(0) - - gridprop2 = xtgeo.gridproperty_from_file(buf, fformat="roff") - - assert gridprop2.name == gridprop.name - np.testing.assert_allclose(gridprop2.values, gridprop.values) - - # deprecated name="unknown" - buf.seek(0) - - with pytest.warns(DeprecationWarning, match="name='unknown'"): - gridprop3 = xtgeo.gridproperty_from_file(buf, name="unknown", fformat="roff") - - assert gridprop3.name == gridprop.name - - def test_gridprops_from_file(testdata_path): g = xtgeo.grid_from_file(testdata_path / GFILE1, fformat="egrid") v1 = xtgeo.gridproperties_from_file( @@ -127,28 +58,8 @@ def test_gridprops_from_file(testdata_path): assert v1.generate_hash() == v2.generate_hash() -def test_gridprop_mask_warns(any_gridprop): - if version.parse(xtgeo_version) >= version.parse("4.0"): - pytest.fail(reason="mask option should be removed") - with pytest.warns(DeprecationWarning, match="mask"): - any_gridprop.get_actnum(mask=True) - - def test_gridprops_mask_warns(any_gridproperties): if version.parse(xtgeo_version) >= version.parse("4.0"): pytest.fail(reason="mask option should be removed") with pytest.warns(DeprecationWarning, match="mask"): any_gridproperties.get_actnum(mask=True) - - -def test_gridproperty_deprecated_init(testdata_path): - with pytest.warns(DeprecationWarning, match="Default initialization"): - gp = GridProperty() - assert gp.ncol == 4 - assert gp.nrow == 3 - assert gp.nlay == 5 - - with pytest.warns(DeprecationWarning, match="from file name"): - GridProperty( - pathlib.Path(testdata_path) / "3dgrids/bri/b_poro.roff", fformat="roff" - ) diff --git a/tests/test_grid3d/test_grid_operations.py b/tests/test_grid3d/test_grid_operations.py index 16c484884..499a01d5b 100644 --- a/tests/test_grid3d/test_grid_operations.py +++ b/tests/test_grid3d/test_grid_operations.py @@ -52,7 +52,7 @@ def test_hybridgrid1(tmp_path, snapshot, helpers): dzv = grd.get_dz() - assert dzv.values3d.mean() == 5.0 + assert dzv.values.mean() == 5.0 grd2 = xtgeo.grid_from_file(tmp_path / "test_hybridgrid1_asis.bgrdecl") snapshot.assert_match( @@ -101,12 +101,12 @@ def test_refine_vertically(testdata_path): emerald_grid = xtgeo.grid_from_file(testdata_path / EMEGFILE) assert emerald_grid.get_subgrids() == {"subgrid_0": 16, "subgrid_1": 30} - avg_dz1 = emerald_grid.get_dz().values3d.mean() + avg_dz1 = emerald_grid.get_dz().values.mean() # idea; either a scalar (all cells), or a dictionary for zone wise emerald_grid.refine_vertically(3) - avg_dz2 = emerald_grid.get_dz().values3d.mean() + avg_dz2 = emerald_grid.get_dz().values.mean() assert avg_dz1 == pytest.approx(3 * avg_dz2, abs=0.0001) diff --git a/tests/test_grid3d/test_grid_property.py b/tests/test_grid3d/test_grid_property.py index adbe952d3..2dafb55fa 100644 --- a/tests/test_grid3d/test_grid_property.py +++ b/tests/test_grid3d/test_grid_property.py @@ -12,7 +12,7 @@ from hypothesis import HealthCheck, example, given, settings from xtgeo.common import XTGeoDialog from xtgeo.common.exceptions import KeywordNotFoundError -from xtgeo.grid3d import Grid, GridProperty +from xtgeo.grid3d import GridProperty from .grid_generator import dimensions, xtgeo_grids from .gridprop_generator import grid_properties @@ -63,10 +63,8 @@ def test_gridproperty_without_name(gridprop): assert gridprop2.name == gridprop.name np.testing.assert_allclose(gridprop2.values, gridprop.values) - # deprecated name="unknown" buf.seek(0) - with pytest.warns(DeprecationWarning, match="name='unknown'"): - gridprop3 = xtgeo.gridproperty_from_file(buf, name="unknown", fformat="roff") + gridprop3 = xtgeo.gridproperty_from_file(buf, name=None, fformat="roff") assert gridprop3.name == gridprop.name np.testing.assert_allclose(gridprop3.values, gridprop.values) @@ -147,12 +145,6 @@ def test_undef(): assert act.undef == xtgeo.UNDEF_INT -def test_class_methods(): - """Test getting class methods""" - result = GridProperty.methods() - assert "from_file" in result - - def test_describe(): """Test getting the describe text""" xx = GridProperty(ncol=3, nrow=2, nlay=1, values=np.array([1, 2, 3, 4, 5, 6])) @@ -170,7 +162,7 @@ def test_discrete_copy(): assert gpcopy.codes == gprop.codes -def test_npvalues3d(): +def test_npvalues(): """Test getting numpy values as 3d""" xx = GridProperty( @@ -294,7 +286,7 @@ def test_roffbin_import2(testdata_path, fformat): testdata_path / TESTFILE2, fformat="roff", name="Oil_HCPV" ) - _ncol, nrow, _nlay = hc.values3d.shape + _ncol, nrow, _nlay = hc.values.shape assert nrow == 100, "NROW from shape (Emerald)" @@ -411,13 +403,13 @@ def test_get_all_corners(testdata_path): z1 = allc[5] # top of cell layer 2 in cell 5 5 (if 1 index start as RMS) - assert x0.values3d[4, 4, 1] == pytest.approx(457387.718, abs=0.5) - assert y0.values3d[4, 4, 1] == pytest.approx(5935461.29790, abs=0.5) - assert z0.values3d[4, 4, 1] == pytest.approx(1728.9429, abs=0.1) + assert x0.values[4, 4, 1] == pytest.approx(457387.718, abs=0.5) + assert y0.values[4, 4, 1] == pytest.approx(5935461.29790, abs=0.5) + assert z0.values[4, 4, 1] == pytest.approx(1728.9429, abs=0.1) - assert x1.values3d[4, 4, 1] == pytest.approx(457526.55367, abs=0.5) - assert y1.values3d[4, 4, 1] == pytest.approx(5935542.02467, abs=0.5) - assert z1.values3d[4, 4, 1] == pytest.approx(1728.57898, abs=0.1) + assert x1.values[4, 4, 1] == pytest.approx(457526.55367, abs=0.5) + assert y1.values[4, 4, 1] == pytest.approx(5935542.02467, abs=0.5) + assert z1.values[4, 4, 1] == pytest.approx(1728.57898, abs=0.1) def test_get_cell_corners(testdata_path): @@ -525,7 +517,7 @@ def test_gridprop_non_default_size_init(dim, discrete): @given(xtgeo_grids, st.booleans()) -@example(Grid(), True) +@example(xtgeo.create_box_grid((4, 3, 5)), True) def test_gridprop_grid_init(grid, discrete): prop = GridProperty( grid, @@ -541,7 +533,7 @@ def test_gridprop_grid_init(grid, discrete): @given(dimensions, xtgeo_grids, st.booleans()) -@example((4, 3, 5), Grid(), True) +@example((4, 3, 5), xtgeo.create_box_grid((4, 3, 5)), True) def test_gridprop_grid_and_dim_init(dim, grid, discrete): ncol, nrow, nlay = dim if dim != grid.dimensions: diff --git a/tests/test_grid3d/test_grid_property_roff.py b/tests/test_grid3d/test_grid_property_roff.py index b777a6e76..cce943d46 100644 --- a/tests/test_grid3d/test_grid_property_roff.py +++ b/tests/test_grid3d/test_grid_property_roff.py @@ -84,7 +84,7 @@ def test_roff_prop_read_xtgeo(tmp_path, xtgeo_property): assert xtgeo_property.nrow == xtgeo_property2.nrow assert xtgeo_property.nlay == xtgeo_property2.nlay assert xtgeo_property.dtype == xtgeo_property2.dtype - assert np.all(xtgeo_property.values3d == xtgeo_property2.values3d) + assert np.all(xtgeo_property.values == xtgeo_property2.values) assert xtgeo_property.codes == xtgeo_property2.codes diff --git a/tests/test_grid3d/test_grid_vs_poly.py b/tests/test_grid3d/test_grid_vs_poly.py index 45c7695cb..3cb85c781 100644 --- a/tests/test_grid3d/test_grid_vs_poly.py +++ b/tests/test_grid3d/test_grid_vs_poly.py @@ -15,7 +15,7 @@ def test_grid_inactivate_inside(tmp_path, testdata_path): p1 = xtgeo.polygons_from_file(testdata_path / REEKPOLY) - act1 = g1.get_actnum().values3d + act1 = g1.get_actnum().values n1 = act1[7, 55, 1] assert n1 == 1 @@ -26,7 +26,7 @@ def test_grid_inactivate_inside(tmp_path, testdata_path): g1.to_file(tmp_path / "reek_inact_ins_pol.roff") - act2 = g1.get_actnum().values3d + act2 = g1.get_actnum().values n2 = act2[7, 55, 1] assert n2 == 0 @@ -37,7 +37,7 @@ def test_grid_inactivate_outside(tmp_path, testdata_path): p1 = xtgeo.polygons_from_file(testdata_path / REEKPOLY) - act1 = g1.get_actnum().values3d + act1 = g1.get_actnum().values n1 = act1[3, 56, 1] assert n1 == 1 @@ -48,7 +48,7 @@ def test_grid_inactivate_outside(tmp_path, testdata_path): g1.to_file(tmp_path / "reek_inact_out_pol.roff") - act2 = g1.get_actnum().values3d + act2 = g1.get_actnum().values n2 = act2[3, 56, 1] assert n2 == 0 diff --git a/tests/test_opm_integration/test_grid_io.py b/tests/test_opm_integration/test_grid_io.py index 5d2c32de0..b1e22f4a2 100644 --- a/tests/test_opm_integration/test_grid_io.py +++ b/tests/test_opm_integration/test_grid_io.py @@ -83,7 +83,7 @@ def test_grdecl_roundtrip(xtgeo_grid): grdecl_file = "xtg_grid.grdecl" xtgeo_grid.to_file(str(grdecl_file), fformat="grdecl") egrid_file = convert_to_egrid(xtgeo_grid.dimensions, grdecl_file) - opm_grid = xtgeo.Grid(str(egrid_file), fformat="egrid") + opm_grid = xtgeo.grid_from_file(str(egrid_file), fformat="egrid") opm_grid._xtgformat2() xtgeo_grid._xtgformat2() @@ -105,7 +105,7 @@ def test_egrid_roundtrip(xtgeo_grid): xtgeo_grid._actnumsv[0] = 0 xtgeo_grid.to_file(str(egrid_file), fformat="egrid") opm_egrid_file = read_write_egrid(xtgeo_grid.dimensions, egrid_file) - opm_grid = xtgeo.Grid(str(opm_egrid_file), fformat="egrid") + opm_grid = xtgeo.grid_from_file(str(opm_egrid_file), fformat="egrid") opm_grid._xtgformat2() xtgeo_grid._xtgformat2()