def _ExtractValueAndError(trace):
    'Returns the value and measure of error from a chartjson trace dict.\n\n  Args:\n    trace: A dict that has one "result" from a performance test, e.g. one\n        "value" in a Telemetry test, with the keys "trace_type", "value", etc.\n\n  Returns:\n    A pair (value, error) where |value| is a float and |error| is some measure\n    of variance used to show error bars; |error| could be None.\n\n  Raises:\n    BadRequestError: Data format was invalid.\n  '
    trace_type = trace.get('type')
    if (trace_type == 'scalar'):
        value = trace.get('value')
        if ((value is None) and trace.get('none_value_reason')):
            return (float('nan'), 0)
        try:
            return (float(value), 0)
        except:
            raise BadRequestError(('Expected scalar value, got: %r' % value))
    if (trace_type == 'list_of_scalar_values'):
        values = trace.get('values')
        if ((not isinstance(values, list)) and (values is not None)):
            raise BadRequestError(('Expected list of scalar values, got: %r' % values))
        if ((not values) or (None in values)):
            if trace.get('none_value_reason'):
                return (float('nan'), float('nan'))
            raise BadRequestError(('Expected list of scalar values, got: %r' % 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')
        if (std is not None):
            error = std
        else:
            error = math_utils.StandardDeviation(values)
        return (value, error)
    if (trace_type == 'histogram'):
        return _GeomMeanAndStdDevFromHistogram(trace)
    raise BadRequestError(('Invalid value type in chart object: %r' % trace_type))
Returns the value and measure of error from a chartjson trace dict.

Args:
  trace: A dict that has one "result" from a performance test, e.g. one
      "value" in a Telemetry test, with the keys "trace_type", "value", etc.

Returns:
  A pair (value, error) where |value| is a float and |error| is some measure
  of variance used to show error bars; |error| could be None.

Raises:
  BadRequestError: Data format was invalid.
def _ExtractValueAndError(trace):
    'Returns the value and measure of error from a chartjson trace dict.\n\n  Args:\n    trace: A dict that has one "result" from a performance test, e.g. one\n        "value" in a Telemetry test, with the keys "trace_type", "value", etc.\n\n  Returns:\n    A pair (value, error) where |value| is a float and |error| is some measure\n    of variance used to show error bars; |error| could be None.\n\n  Raises:\n    BadRequestError: Data format was invalid.\n  '
    trace_type = trace.get('type')
    if (trace_type == 'scalar'):
        value = trace.get('value')
        if ((value is None) and trace.get('none_value_reason')):
            return (float('nan'), 0)
        try:
            return (float(value), 0)
        except:
            raise BadRequestError(('Expected scalar value, got: %r' % value))
    if (trace_type == 'list_of_scalar_values'):
        values = trace.get('values')
        if ((not isinstance(values, list)) and (values is not None)):
            raise BadRequestError(('Expected list of scalar values, got: %r' % values))
        if ((not values) or (None in values)):
            if trace.get('none_value_reason'):
                return (float('nan'), float('nan'))
            raise BadRequestError(('Expected list of scalar values, got: %r' % 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')
        if (std is not None):
            error = std
        else:
            error = math_utils.StandardDeviation(values)
        return (value, error)
    if (trace_type == 'histogram'):
        return _GeomMeanAndStdDevFromHistogram(trace)
    raise BadRequestError(('Invalid value type in chart object: %r' % trace_type))