Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(742)

Unified Diff: dashboard/dashboard/add_point.py

Issue 1935593002: Also accept long values in lists of scalar values. (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dashboard/dashboard/add_point_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dashboard/dashboard/add_point.py
diff --git a/dashboard/dashboard/add_point.py b/dashboard/dashboard/add_point.py
index 7e1d620e9f98d21c3062b68e04f6a9807fe20789..e88a607db2dc6fa8da36c537ab5c4ac32e8df97b 100644
--- a/dashboard/dashboard/add_point.py
+++ b/dashboard/dashboard/add_point.py
@@ -425,7 +425,7 @@ def _ExtractValueAndError(trace):
if trace.get('none_value_reason'):
return float('nan'), float('nan')
raise BadRequestError('Expected list of scalar values, got: %r' % values)
- if not all(isinstance(v, float) or isinstance(v, int) for v in values):
+ if not all(_IsNumber(v) for v in values):
raise BadRequestError('Non-number found in values list: %r' % values)
value = math_utils.Mean(values)
std = trace.get('std')
@@ -441,6 +441,10 @@ def _ExtractValueAndError(trace):
raise BadRequestError('Invalid value type in chart object: %r' % trace_type)
+def _IsNumber(v):
+ return isinstance(v, float) or isinstance(v, int) or isinstance(v, long)
+
+
def _EscapeName(name):
"""Escapes a trace name so it can be stored in a row.
« no previous file with comments | « no previous file | dashboard/dashboard/add_point_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698