parameters: (trace)
docstring: 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.
docstring_summary: Returns the value and measure of error from a chartjson trace dict.
docstring_tokens: Returns the value and measure of error from a chartjson trace dict .
function: def _ExtractValueAndError(trace):
    """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.
    """
    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:
        # Something else (such as a single scalar, or string) was given.
        raise BadRequestError('Expected list of scalar values, got: %r' % values)
      if not values or None in values:
        # None was included or values is None; this is not an error if there
        # is a reason.
        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)
function_tokens: def _ExtractValueAndError ( trace ) : 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 : # Something else (such as a single scalar, or string) was given. raise BadRequestError ( 'Expected list of scalar values, got: %r' % values ) if not values or None in values : # None was included or values is None; this is not an error if there # is a reason. 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 )