Skip to content

Commit

Permalink
Make type_name a method in rd_kw
Browse files Browse the repository at this point in the history
  • Loading branch information
larsevj committed Aug 29, 2024
1 parent d530d59 commit 8672735
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions python/resdata/grid/faults/fault_block_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def scan_keyword(self, fault_block_kw):
raise ValueError(
"The fault block keyword had wrong type/size: type:%s size:%d grid_size:%d"
% (
fault_block_kw.type_name,
fault_block_kw.type_name(),
len(fault_block_kw),
self.grid_ref.getGlobalSize(),
)
Expand All @@ -126,7 +126,7 @@ def load_keyword(self, fault_block_kw):
raise ValueError(
"The fault block keyword had wrong type/size: type:%s size:%d grid_size:%d"
% (
fault_block_kw.type_name,
fault_block_kw.type_name(),
len(fault_block_kw),
self.grid_ref.getGlobalSize(),
)
Expand Down
4 changes: 2 additions & 2 deletions python/resdata/grid/rd_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ def select_equal(self, rd_kw, value, intersect=False):
if not rd_kw.data_type.is_int():
raise ValueError(
"The select_equal method must have an integer valued keyword - got:%s"
% rd_kw.type_name
% rd_kw.type_name()
)
self._select_equal(rd_kw, value)

Expand All @@ -565,7 +565,7 @@ def deselect_equal(self, rd_kw, value):
if not rd_kw.data_type.is_int():
raise ValueError(
"The select_equal method must have an integer valued keyword - got:%s"
% rd_kw.type_name
% rd_kw.type_name()
)
self._deselect_equal(rd_kw, value)

Expand Down
5 changes: 2 additions & 3 deletions python/resdata/resfile/rd_kw.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,6 @@ def type(self):
def data_type(self):
return self._get_data_type()

@property
def type_name(self):
return self.data_type.type_name

Expand All @@ -991,7 +990,7 @@ def get_rd_type(self):

@property
def header(self):
return (self.get_name(), len(self), self.type_name)
return (self.get_name(), len(self), self.type_name())

@property
def array(self):
Expand Down Expand Up @@ -1033,7 +1032,7 @@ def str(self, width=5, max_lines=10, fmt=None):
the elements. The implementation of the builtin method
__str__() is based on this method.
"""
s = "%-8s %8d %-4s\n" % (self.get_name(), len(self), self.type_name)
s = "%-8s %8d %-4s\n" % (self.get_name(), len(self), self.type_name())
lines = len(self) // width
if not fmt:
fmt = self.str_fmt + " "
Expand Down
2 changes: 1 addition & 1 deletion python/tests/rd_tests/test_rd_kw.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def test_resize(self):
def test_typename(self):
kw = ResdataKW("KW", 100, ResDataType.RD_INT)

self.assertEqual(kw.type_name, "INTE")
self.assertEqual(kw.type_name(), "INTE")

def test_string_alloc(self):
kw = ResdataKW("KW", 10, ResDataType.RD_STRING(30))
Expand Down

0 comments on commit 8672735

Please sign in to comment.