add early return if there are no timestrings in pred and ref
Browse files- logscoremetric.py +5 -1
logscoremetric.py
CHANGED
@@ -108,9 +108,13 @@ class LogScoreMetric(evaluate.Metric):
|
|
108 |
if(len(pred_timestrings) != len(ref_timestrings)):
|
109 |
return 0.0
|
110 |
|
|
|
|
|
|
|
|
|
111 |
# replace all digits in the reference timestamp (first timestamp) with '/d' to get
|
112 |
# a regex that describes the format
|
113 |
-
pred_timestring_pattern = re.sub(r'\d', r'\\d', re.escape(pred_timestrings[0]))
|
114 |
|
115 |
# A variable to save the previous timestamp (as datetime obj) to check monotonicity
|
116 |
prev_datetime = None
|
|
|
108 |
if(len(pred_timestrings) != len(ref_timestrings)):
|
109 |
return 0.0
|
110 |
|
111 |
+
# If there are no timestrings, we must not check anything, we can directly return 1.0
|
112 |
+
if (len(pred_timestrings) == 0):
|
113 |
+
return 1.0
|
114 |
+
|
115 |
# replace all digits in the reference timestamp (first timestamp) with '/d' to get
|
116 |
# a regex that describes the format
|
117 |
+
pred_timestring_pattern = re.sub(r'\d', r'\\d', re.escape(pred_timestrings[0]))
|
118 |
|
119 |
# A variable to save the previous timestamp (as datetime obj) to check monotonicity
|
120 |
prev_datetime = None
|