From cef6bab2501f46a5afa0a9c77809e317f9416b9b Mon Sep 17 00:00:00 2001 From: Dmitry Date: Sun, 17 Sep 2017 23:37:29 -0700 Subject: [PATCH] Parse scientific float format in target files --- dvc/git_wrapper.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dvc/git_wrapper.py b/dvc/git_wrapper.py index 5dc945e4e..9bbb0e2ba 100644 --- a/dvc/git_wrapper.py +++ b/dvc/git_wrapper.py @@ -91,6 +91,8 @@ class GitWrapperI(object): class GitWrapper(GitWrapperI): + FLOATS_FROM_STRING = re.compile(r'[-+]?(?:(?:\d*\.\d+)|(?:\d+\.?))(?:[Ee][+-]?\d+)?') + def __init__(self): super(GitWrapper, self).__init__() @@ -330,13 +332,13 @@ class GitWrapper(GitWrapperI): return None # Extract float from string. I.e. from 'AUC: 0.596182' - num = re.findall("\d+\.\d+", lines[0]) - if len(num) != 1: + nums = self.FLOATS_FROM_STRING.findall(lines[0]) + if len(nums) < 1: msg = '[dvc-git] Unable to parse metrics from \'{}\' file {}' Logger.warn(msg.format(lines[0], target)) return None - return float(num[0]) + return float(nums[0]) @staticmethod def get_merges_map():