-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved get_matching_vector_names function to new utils module
- Loading branch information
Øyvind Lind-Johansen
committed
May 19, 2022
1 parent
b66366a
commit 02e13b2
Showing
4 changed files
with
33 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
webviz_subsurface/_providers/ensemble_summary_provider/utils.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import fnmatch | ||
import re | ||
from typing import List | ||
|
||
from .ensemble_summary_provider import EnsembleSummaryProvider | ||
|
||
|
||
def get_matching_vector_names( | ||
provider: EnsembleSummaryProvider, column_keys: List[str] | ||
) -> List[str]: | ||
"""Returns a list of vectors that match the input columns_keys that | ||
can have unix shell wildcards. | ||
Example of use: | ||
column_keys = ["FOPT", "WGOR*"] | ||
matching_vector_names = get_matching_vector_names(provider, column_keys) | ||
df = provider.get_vectors_df(matching_vector_names, None) | ||
""" | ||
try: | ||
regex = re.compile( | ||
"|".join([fnmatch.translate(col) for col in column_keys]), | ||
flags=re.IGNORECASE, | ||
) | ||
return [vec for vec in provider.vector_names() if regex.fullmatch(vec)] | ||
except re.error: | ||
return [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters