Skip to content

Commit

Permalink
Compress fipxxx (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
alifbe committed May 10, 2024
1 parent c54045c commit a5810b4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/subscript/eclcompress/eclcompress.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def find_keyword_sets(filelines: List[str]) -> List[Tuple[int, int]]:
/
we are not able to detect anything but the first record (line) without
having a full Eclipse parser (OPM). This means we we only compress the
having a full Eclipse parser (OPM). This means we only compress the
first line. These type of keywords are not important to compress, and we
could just as well avoid compressing them altogether.
Expand All @@ -336,7 +336,7 @@ def find_keyword_sets(filelines: List[str]) -> List[Tuple[int, int]]:
continue
# Remove embracing quotes if in a multi-keyword
keyword = line.split(" ")[0].strip("'")
if keyword in ALLOWLIST_KEYWORDS:
if (keyword in ALLOWLIST_KEYWORDS) or keyword.startswith("FIP"):
kwstart = lineidx
if "/" in line:
keywordsets.append((kwstart, lineidx))
Expand Down
23 changes: 23 additions & 0 deletions tests/test_eclcompress.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,29 @@ def test_only_allowlist_compressed(tmp_path):
assert compress_multiple_keywordsets(kw_sets, filelines) == expected


def test_compress_fipxxx(tmp_path):
"""Ensure that FIPxxxxx keywords are compressed"""
given = """
FIPLIC
3 3 3 3 /
FIPPOLY
2 4 4 5 5 6
/
"""
filelines = given.splitlines()
kw_sets = find_keyword_sets(filelines)
expected = [
"",
"FIPLIC",
" 4*3 /",
"FIPPOLY",
" 2 2*4 2*5 6",
"/",
]

assert compress_multiple_keywordsets(kw_sets, filelines) == expected


def test_whitespace(tmp_path):
"""Ensure excessive whitespace is not added"""
kw_string = """
Expand Down

0 comments on commit a5810b4

Please sign in to comment.