Skip to content
Merged
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
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ test = [
"pytest-timeout",
"hypothesis",
"pydantic",
"typing_extensions",
"resfo-utilities[testing]>=0.4.0",
"numpy",
"pandas",
Expand All @@ -27,7 +26,6 @@ format = ["cmake-format", "clang-format", "black"]
[tool.pytest.ini_options]
addopts = "--strict-markers"
testpaths = ["tests"]

[tool.cibuildwheel]
build-frontend = "build[uv]"
build = "cp311-* cp312-* cp313-* cp314-*"
Expand Down
3 changes: 1 addition & 2 deletions python/resdata/geometry/surface.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from __future__ import division

"""
Create a polygon
"""

import os.path
import ctypes

Expand Down
1 change: 0 additions & 1 deletion python/resdata/grid/faults/fault_block_layer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import print_function
from cwrap import BaseCClass

from resdata.util.util import monkey_the_camel
Expand Down
2 changes: 0 additions & 2 deletions python/resdata/grid/faults/fault_segments.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function

from resdata.util.util import monkey_the_camel


Expand Down
11 changes: 5 additions & 6 deletions python/resdata/grid/rd_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import math
import itertools
from cwrap import CFILE, BaseCClass, load, open as copen
from typing_extensions import deprecated

from resdata import ResdataPrototype
from resdata.util.util import monkey_the_camel
Expand Down Expand Up @@ -269,19 +270,17 @@ def create(cls, specgrid, zcorn, coord, actnum, mapaxes=None):
)

@classmethod
@deprecated(
"Grid.createRectangular is deprecated. It will be removed in version 7. "
"Please use the similar method: GridGenerator.createRectangular.",
)
def create_rectangular(cls, dims, dV, actnum=None):
"""
Will create a new rectangular grid. @dims = (nx,ny,nz) @dVg = (dx,dy,dz)

With the default value @actnum == None all cells will be active,
"""

warnings.warn(
"Grid.createRectangular is deprecated. "
+ "Please use the similar method: GridGenerator.createRectangular.",
DeprecationWarning,
)

if actnum is None:
rd_grid = cls._alloc_rectangular(
dims[0], dims[1], dims[2], dV[0], dV[1], dV[2], None
Expand Down
2 changes: 0 additions & 2 deletions python/resdata/rd_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
functions from rd_util.c which are not bound to any class type.
"""

from __future__ import absolute_import

import ctypes

from cwrap import BaseCEnum
Expand Down
6 changes: 5 additions & 1 deletion python/resdata/resfile/rd_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import ctypes
import datetime
import re
from typing_extensions import deprecated

from cwrap import BaseCClass
from resdata import FileMode, FileType, ResdataPrototype
Expand Down Expand Up @@ -575,8 +576,11 @@ def __exit__(self, exc_type, exc_val, exc_tb):
return False


@deprecated(
"The function openResdataFile is deprecated, "
"and will be removed in version 7. Use open_rd_file."
)
def openResdataFile(file_name, flags=FileMode.DEFAULT):
print("The function openResdataFile is deprecated, use open_rd_file.")
return open_rd_file(file_name, flags)


Expand Down
1 change: 0 additions & 1 deletion python/resdata/resfile/rd_file_view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import absolute_import, division, print_function, unicode_literals
from six import string_types
from cwrap import BaseCClass
from resdata.util.util import monkey_the_camel
Expand Down
14 changes: 7 additions & 7 deletions python/resdata/resfile/rd_kw.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import ctypes
import warnings
from typing_extensions import deprecated

import numpy as np
from cwrap import CFILE, BaseCClass
Expand Down Expand Up @@ -981,8 +982,10 @@ def get_min(self):
return mm[0]

@property
@deprecated(
"rd_kw.type is deprecated, it will be removed in version 7. Use .data_type."
)
def type(self):
warnings.warn("rd_kw.type is deprecated, use .data_type", DeprecationWarning)
return self._get_type()

@property
Expand All @@ -992,13 +995,10 @@ def data_type(self):
def type_name(self):
return self.data_type.type_name

@deprecated(
"ResdataTypeEnum is deprecated. You should instead provide an ResDataType",
)
def get_rd_type(self):
warnings.warn(
"ResdataTypeEnum is deprecated. "
+ "You should instead provide an ResDataType",
DeprecationWarning,
)

return self._get_type()

@property
Expand Down
12 changes: 6 additions & 6 deletions python/resdata/rft/rd_rft.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from resfo_utilities import RFTReader
import fnmatch
import warnings
from typing_extensions import deprecated


def to_float_or_none(value: np.float32 | None) -> float | None:
Expand Down Expand Up @@ -211,6 +212,11 @@ def category_to_type_str(s: str) -> str | None:
return None


@deprecated(
"ResdataRFTFile is deprecated and will be removed in version 7, see "
"resfo-utilities.readthedocs.io/en/latest/user_guide.html"
"#module-resfo_utilities._rft_reader to migrate to resfo-utilities. ",
)
class ResdataRFTFile:
"""Used to load an RFT file.

Expand All @@ -223,12 +229,6 @@ class ResdataRFTFile:
"""

def __init__(self, case: str | PathLike[str]) -> None:
warnings.warn(
"ResdataRFTFile is deprecated, see "
"resfo-utilities.readthedocs.io/en/latest/user_guide.html"
"#module-resfo_utilities._rft_reader to migrate to resfo-utilities.",
DeprecationWarning,
)
try:
with RFTReader.open(case) as rft:
self._entries = [
Expand Down
84 changes: 46 additions & 38 deletions python/resdata/summary/rd_sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import pandas as pd
import re
from typing import Sequence, List, Tuple, Optional, Union
from textwrap import dedent
from typing_extensions import deprecated

# Observe that there is some convention conflict with the C code
# regarding order of arguments: The C code generally takes the time
Expand Down Expand Up @@ -397,17 +399,17 @@ def add_t_step(self, report_step, sim_days):
tstep = self._add_tstep(report_step, sim_seconds).setParent(parent=self)
return tstep

@deprecated(
"The method get_vector() is deprecated, and will be removed in version 7."
" Use numpy_vector() instead"
)
def get_vector(self, key, report_only=False):
"""
Will return SummaryVector according to @key.

Will raise exception KeyError if the summary object does not
have @key.
"""
warnings.warn(
"The method get_vector() has been deprecated, use numpy_vector() instead",
DeprecationWarning,
)
self.assertKeyValid(key)
if report_only:
return SummaryVector(self, key, report_only=True)
Expand Down Expand Up @@ -446,6 +448,10 @@ def groups(self, pattern=None):
"""
return self._create_group_list(pattern)

@deprecated(
"The method get_values() is deprecated, and will be removed in version 7."
" Use numpy_vector() instead."
)
def get_values(self, key, report_only=False):
"""
Will return numpy vector of all values according to @key.
Expand All @@ -455,10 +461,6 @@ def get_values(self, key, report_only=False):
also available as the 'values' property of an SummaryVector
instance.
"""
warnings.warn(
"The method get_values() has been deprecated - use numpy_vector() instead.",
DeprecationWarning,
)
if self.has_key(key):
key_index = self._get_general_var_index(key)
if report_only:
Expand Down Expand Up @@ -800,11 +802,11 @@ def first_value(self, key):

return self._get_first_value(key)

@deprecated(
"The function get_last_value() is deprecated, and will be removed in"
" version 7. Use last_value() instead"
)
def get_last_value(self, key):
warnings.warn(
"The function get_last_value() is deprecated, use last_value() instead",
DeprecationWarning,
)
return self.last_value(key)

def get_last(self, key):
Expand Down Expand Up @@ -869,37 +871,43 @@ def assert_key_valid(self, key):
def __iter__(self):
return iter(self.keys())

@deprecated(
"The method the [] operator will change behaviour in version 7."
" It will then return a plain numpy vector. You are advised to change to"
" use the numpy_vector() method right away",
)
def __getitem__(self, key):
"""
Implements [] operator - @key should be a summary key.

The returned value will be a SummaryVector instance.
"""
warnings.warn(
"The method the [] operator will change behaviour in the future. It will then return a plain numpy vector. You are advised to change to use the numpy_vector() method right away",
DeprecationWarning,
)
return self.get_vector(key)

def scale_vector(self, key, scalar):
msg = """The function Summary.scale_vector has been removed. As an alternative you
are advised to fetch vector as a numpy vector and then scale that yourself:
raise NotImplementedError(
dedent(
"""The function Summary.scale_vector has been removed. As an alternative you
are advised to fetch vector as a numpy vector and then scale that yourself:

vec = rd_sum.numpy_vector(key)
vec *= scalar
vec = rd_sum.numpy_vector(key)
vec *= scalar

"""
raise NotImplementedError(msg)
"""
)
)

def shift_vector(self, key, addend):
msg = """The function Summary.shift_vector has been removed. As an alternative you
are advised to fetch vector as a numpy vector and then scale that yourself:

vec = rd_sum.numpy_vector(key)
vec += scalar

"""
raise NotImplementedError(msg)
raise NotImplementedError(
dedent(
"""The function Summary.shift_vector has been removed. As an alternative you
are advised to fetch vector as a numpy vector and then scale that yourself:

vec = rd_sum.numpy_vector(key)
vec += scalar
"""
)
)

def check_sim_time(self, date):
"""
Expand Down Expand Up @@ -1259,6 +1267,10 @@ def get_dates(self, report_only=False):
return self.dates

@property
@deprecated(
"The mpl_dates property is deprecated and will be removed in version 7."
" Use numpy_dates instead"
)
def mpl_dates(self):
"""
Will return a numpy vector of dates ready for matplotlib
Expand All @@ -1267,12 +1279,12 @@ def mpl_dates(self):
i.e. floats - generated by the date2num() function at the top
of this file.
"""
warnings.warn(
"The mpl_dates property has been deprecated - use numpy_dates instead",
DeprecationWarning,
)
return self.get_mpl_dates(False)

@deprecated(
"The get_mpl_dates( ) method is deprecated and will be removed in"
" version 7. Use numpy_dates instead",
)
def get_mpl_dates(self, report_only=False):
"""
Will return a numpy vector of dates ready for matplotlib
Expand All @@ -1283,10 +1295,6 @@ def get_mpl_dates(self, report_only=False):
format, i.e. floats - generated by the date2num() function at
the top of this file.
"""
warnings.warn(
"The get_mpl_dates( ) method has been deprecated - use numpy_dates instead",
DeprecationWarning,
)
if report_only:
return [date2num(dt) for dt in self.report_dates]
else:
Expand Down
15 changes: 8 additions & 7 deletions python/resdata/summary/rd_sum_vector.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import print_function
import warnings
from typing_extensions import deprecated


from .rd_sum_node import SummaryNode


Expand Down Expand Up @@ -27,7 +29,7 @@ def __init__(self, parent, key, report_only=False):

if report_only:
warnings.warn(
"The report_only flag to the SummaryVector will be removed",
"The report_only flag to the SummaryVector will be removed in version 7.",
DeprecationWarning,
)

Expand Down Expand Up @@ -88,18 +90,17 @@ def days(self):
return self.__days

@property
@deprecated(
"The mpl_dates property has been deprecated, and will be "
"removed in version 7. Use numpy_dates instead"
)
def mpl_dates(self):
"""
All the dates as numpy vector of dates in matplotlib format.
This property will be replaced by numpy_dates, but is kept for
backwards-compatibility for the time-being. Usage will trigger
a depreciation warning.
"""
warnings.warn(
"The mpl_dates property has been deprecated - use numpy_dates instead",
DeprecationWarning,
)

return self.parent.get_mpl_dates(self.report_only)

@property
Expand Down
2 changes: 2 additions & 0 deletions python/resdata/util/test/debug_msg.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import inspect
from typing_extensions import deprecated


@deprecated("debug_msg is deprecated and will be removed in version 7")
def debug_msg(msg):
record = inspect.stack()[1]
frame = record[0]
Expand Down
Loading
Loading