Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compress fipxxx #696

Merged
merged 3 commits into from
May 10, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
run: |
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:opm/ppa
sudo apt-add-repository ppa:opm/testing
sudo apt-get update
sudo apt-get install mpi-default-bin
sudo apt-get install libopm-simulators-bin
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/subscript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
run: |
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:opm/ppa
sudo apt-add-repository ppa:opm/testing
sudo apt-get update
sudo apt-get install mpi-default-bin
sudo apt-get install libopm-simulators-bin
Expand Down
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