diff --git a/python/resdata/resfile/rd_file.py b/python/resdata/resfile/rd_file.py index 04c074748..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 @@ -51,9 +50,6 @@ class ResdataFile(BaseCClass): "int rd_file_get_restart_index(rd_file, rd_time_t)" ) _get_src_file = ResdataPrototype("char* rd_file_get_src_file(rd_file)") - _replace_kw = ResdataPrototype( - "void rd_file_replace_kw(rd_file, rd_kw, rd_kw, bool)" - ) _fwrite = ResdataPrototype("void rd_file_fwrite_fortio(rd_file, rd_fortio, int)") _has_report_step = ResdataPrototype("bool rd_file_has_report_step(rd_file, int)") _has_sim_time = ResdataPrototype("bool rd_file_has_sim_time(rd_file, rd_time_t)") @@ -88,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): """ @@ -261,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. @@ -435,40 +376,6 @@ def restart_get_kw(self, kw_name, dtime, copy=False): 'Does not have keyword "%s" at time:%s.' % (kw_name, dtime) ) - def replace_kw(self, old_kw, new_kw): - """ - Will replace @old_kw with @new_kw in current ResdataFile instance. - - This method can be used to replace one of the ResdataKW instances - in the current ResdataFile. The @old_kw reference must be to the - actual ResdataKW instance in the current ResdataFile instance (the - final comparison is based on C pointer equality!), i.e. it - must be a reference (not a copy) from one of the ??get_kw?? - methods of the ResdataFile class. In the example below we replace - the SWAT keyword from a restart file: - - swat = file.iget_named_kw( "SWAT" , 0 ) - new_swat = swat * 0.25 - file.replace_kw( swat , new_swat ) - - - The C-level rd_file_type structure takes full ownership of - all installed rd_kw instances; mixing the garbage collector - into it means that this is quite low level - and potentially - dangerous! - """ - - # We ensure that this scope owns the new_kw instance; the - # new_kw will be handed over to the rd_file instance, and we - # can not give away something we do not alreeady own. - if not new_kw.data_owner: - new_kw = ResdataKW.copy(new_kw) - - # The rd_file instance will take responsability for freeing - # this rd_kw instance. - new_kw.data_owner = False - self._replace_kw(old_kw, new_kw, False) - @property def size(self): """ 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")