From 40e53459e5c04f4fe721415edba647bdc9ecfd78 Mon Sep 17 00:00:00 2001 From: "Shenhui,Ruan" Date: Tue, 23 Jul 2024 23:26:21 +0200 Subject: [PATCH 1/2] Add a new selection latestTime to the parameter fields_time_instants --- smithers/io/openfoam/openfoamhandler.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/smithers/io/openfoam/openfoamhandler.py b/smithers/io/openfoam/openfoamhandler.py index f486087..8b169b3 100644 --- a/smithers/io/openfoam/openfoamhandler.py +++ b/smithers/io/openfoam/openfoamhandler.py @@ -186,6 +186,8 @@ def _find_time_instants_subfolders(cls, path, fields_time_instants): * `'first'`: same of `'all_numeric'`, but return only the folder whose name is the smallest number of the set; * `'not_first'`: same of `'all_numeric'`, but exclude the first folder; + * `'latestTime'`: same of `'all_numeric'`, but return only the folder whose + name is the largest number of the set; * a list of folder names. :type fields_time_instants: str or list :returns: A list of tuples (first item: subfolder name, second item: @@ -209,6 +211,7 @@ def is_numeric(x): fields_time_instants == "all_numeric" or fields_time_instants == "first" or fields_time_instants == "not_first" + or fields_time_instants == "latestTime" ): subfolders = next(os.walk(path))[1] subfolders = list(filter(is_numeric, subfolders)) @@ -220,6 +223,8 @@ def is_numeric(x): time_instant_subfolders = subfolders elif fields_time_instants == "not_first": time_instant_subfolders = sorted(subfolders)[1:] + elif fields_time_instants == "latestTime": + time_instant_subfolders = [sorted(subfolders)[-1]] else: # we want a list in order to return an iterable object time_instant_subfolders = [sorted(subfolders)[0]] From 0ed5eef94cba76a302561856a1e3512f19718e20 Mon Sep 17 00:00:00 2001 From: "Shenhui,Ruan" Date: Tue, 23 Jul 2024 23:43:30 +0200 Subject: [PATCH 2/2] modify the too long line --- smithers/io/openfoam/openfoamhandler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smithers/io/openfoam/openfoamhandler.py b/smithers/io/openfoam/openfoamhandler.py index 8b169b3..7dd3b99 100644 --- a/smithers/io/openfoam/openfoamhandler.py +++ b/smithers/io/openfoam/openfoamhandler.py @@ -186,8 +186,8 @@ def _find_time_instants_subfolders(cls, path, fields_time_instants): * `'first'`: same of `'all_numeric'`, but return only the folder whose name is the smallest number of the set; * `'not_first'`: same of `'all_numeric'`, but exclude the first folder; - * `'latestTime'`: same of `'all_numeric'`, but return only the folder whose - name is the largest number of the set; + * `'latestTime'`: same of `'all_numeric'`, but return only the folder + whose name is the largest number of the set; * a list of folder names. :type fields_time_instants: str or list :returns: A list of tuples (first item: subfolder name, second item: