From a8fdcf3a3b9c55b5d230baf1ea40fb6688025bd4 Mon Sep 17 00:00:00 2001 From: Eivind Jahren Date: Tue, 23 Apr 2024 12:31:30 +0200 Subject: [PATCH] Remove deprecated functions from ResdataFile These functions have thrown NotImplementedError for a long time so it should now be considered removing undefined behavior in terms of semver. --- python/resdata/resfile/rd_file.py | 58 +-------------------------- python/tests/rd_tests/test_removed.py | 31 -------------- 2 files changed, 1 insertion(+), 88 deletions(-) delete mode 100644 python/tests/rd_tests/test_removed.py diff --git a/python/resdata/resfile/rd_file.py b/python/resdata/resfile/rd_file.py index a1180f957..4b4303159 100644 --- a/python/resdata/resfile/rd_file.py +++ b/python/resdata/resfile/rd_file.py @@ -24,11 +24,10 @@ import ctypes import datetime import re -import types from cwrap import BaseCClass from resdata import FileMode, FileType, ResdataPrototype -from resdata.resfile import ResdataFileView, ResdataKW +from resdata.resfile import ResdataKW from resdata.util.util import CTime, monkey_the_camel @@ -85,12 +84,6 @@ def get_filetype(filename): return (file_type, report_step, fmt_file) - @classmethod - def restart_block(cls, filename, dtime=None, report_step=None): - raise NotImplementedError( - "The restart_block implementation has been removed - open file normally and use ResdataFileView." - ) - @classmethod def contains_report_step(cls, filename, report_step): """ @@ -258,55 +251,6 @@ def restart_view( seqnum_index, report_step, sim_time, sim_days ) - def select_block(self, kw, kw_index): - raise NotImplementedError( - "The select_block implementation has been removed - use ResdataFileView" - ) - - def select_global(self): - raise NotImplementedError( - "The select_global implementation has been removed - use ResdataFileView" - ) - - def select_restart_section(self, index=None, report_step=None, sim_time=None): - raise NotImplementedError( - "The select_restart_section implementation has been removed - use ResdataFileView" - ) - """ - Will select a restart section as the active section. - - You must specify a report step with the @report_step argument, - a true time with the @sim_time argument or a plain index to - select restart block. If none of arguments are given exception - TypeError will be raised. If present the @sim_time argument - should be a datetime instance. - - If the restart section you ask for can not be found the method - will raise a ValueError exeception. To protect against this - you can query first with the has_report_step(), - has_sim_time() or num_report_steps() methods. - - This method should be used when you have already loaded the - complete file; if you only want to load a section from the - file you can use the classmethod restart_block(). - - The method will return 'self' which can be used to aid - readability. - """ - - def select_last_restart(self): - raise NotImplementedError( - "The select_restart_section implementation has been removed - use ResdataFileView" - ) - """ - Will select the last SEQNUM block in restart file. - - Works by searching for the last SEQNUM keyword; the SEQNUM - Keywords are only present in unified restart files. If this - is a non-unified restart file (or not a restart file at all), - the method will do nothing and return False. - """ - def __getitem__(self, index): """ Implements [] operator; index can be integer or key. diff --git a/python/tests/rd_tests/test_removed.py b/python/tests/rd_tests/test_removed.py deleted file mode 100644 index fc186de1a..000000000 --- a/python/tests/rd_tests/test_removed.py +++ /dev/null @@ -1,31 +0,0 @@ -import time -import datetime - -from resdata.util.test import TestAreaContext -from tests import ResdataTest -from resdata import ResDataType -from resdata.resfile import ResdataFile, ResdataKW, openFortIO, FortIO - - -class Removed_2_1_Test(ResdataTest): - def test_rd_file_block(self): - with TestAreaContext("name") as t: - kw = ResdataKW("TEST", 3, ResDataType.RD_INT) - with openFortIO("TEST", mode=FortIO.WRITE_MODE) as f: - kw.fwrite(f) - - f = ResdataFile("TEST") - with self.assertRaises(NotImplementedError): - f.select_block("KW", 100) - - with self.assertRaises(NotImplementedError): - f.select_global() - - with self.assertRaises(NotImplementedError): - f.select_restart_section(index=None, report_step=None, sim_time=None) - - with self.assertRaises(NotImplementedError): - f.select_restart_section() - - with self.assertRaises(NotImplementedError): - ResdataFile.restart_block("TEST")