Get a dictionary of measurement positions.
552389
def get_positions(self, copy=True):
        '''
        
        '''
        if copy:
            return self._positions.copy()
        else:
            return self._positions
911585
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'aggregations' in _dict:
            args['aggregations'] = [
                MetricAggregation._from_dict(x)
                for x in (_dict.get('aggregations'))
            ]
        return cls(**args)
706760
def get_dimensions_units(names):
    """"""
    dimensions_uni = {}

    for name in names:

        key = get_key_from_dimensions(names[name].dimensions)
        dimensions_uni[key] = names[name]
        plain_dimensions = [{'base': name, 'power': 1}]
        key = get_key_from_dimensions(plain_dimensions)
        dimensions_uni[key] = names[name]

        if not names[name].dimensions:
            names[name].dimensions = plain_dimensions

        names[name].dimensions = [{'base': names[i['base']].name,
                                   'power': i['power']} for i in
                                  names[name].dimensions]

    return dimensions_uni
1257024
def get_usages(self):
        ""
        result = dict()
        for key, usage in self.items():
            result[key] = usage.value
        return result
459922
async def info(self):
        '''
        
        '''
        stat = self._items.stat()
        return {'indx': self._items.index(), 'metrics': self._metrics.index(), 'stat': stat}
572265
def valuesToDict(key):
    """"""
    d = {}
    size = _winreg.QueryInfoKey(key)[1]
    for i in xrange(size):
        d[_winreg.EnumValue(key, i)[0]] = _winreg.EnumValue(key, i)[1]
    return d
782919
def pos(self):
        
        pos = self._pos
        if pos is None:
            return self.p0
        # convert to dict
        pos = {param: self._pos[..., k]
               for (k, param) in enumerate(self.sampling_params)}
        return pos
1244247
def submit_statsd_measurements(self):
        """"""
        for key, value in self.measurement.counters.items():
            self.statsd.incr(key, value)
        for key, values in self.measurement.durations.items():
            for value in values:
                self.statsd.add_timing(key, value)
        for key, value in self.measurement.values.items():
            self.statsd.set_gauge(key, value)
        for key, value in self.measurement.tags.items():
            if isinstance(value, bool):
                if value:
                    self.statsd.incr(key)
            elif isinstance(value, str):
                if value:
                    self.statsd.incr('{}.{}'.format(key, value))
            elif isinstance(value, int):
                self.statsd.incr(key, value)
            else:
                LOGGER.warning('The %s value type of %s is unsupported',
                               key, type(value))
1084540
def items(self):
        
        items = []
        for series in self._get_series():
            series_key = (series.get('measurement',
                                     series.get('name', 'results')),
                          series.get('tags', None))
            items.append(
                (series_key, self._get_points_for_series(series))
            )
        return items
1328435
def info(self):
        """"""
        return {'coordinates': self._coordinates(),
                'imageinfo': self._imageinfo(),
                'miscinfo': self._miscinfo(),
                'unit': self._unit()
                }
137086
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'event_type' in _dict:
            args['event_type'] = _dict.get('event_type')
        if 'results' in _dict:
            args['results'] = [
                MetricTokenAggregationResult._from_dict(x)
                for x in (_dict.get('results'))
            ]
        return cls(**args)
155811
def get_individual_positions(individuals):
    
    ind_pos = {}
    if individuals:
        for i, ind in enumerate(individuals):
            ind_pos[ind] = i
    return ind_pos
1043649
def measurements(self):
        
        if 'measurements' in self._values:
            return self._values['measurements']
        self._values['measurements'] = copy.deepcopy(self._defaults['measurements'])
        return self._values['measurements']
668537
def multidim_measurement_to_attachment(name, measurement):
  """"""

  dimensions = list(measurement.dimensions)
  if measurement.units:
    dimensions.append(
        measurements.Dimension.from_unit_descriptor(measurement.units))

  dims = []
  for d in dimensions:
    if d.suffix is None:
      suffix = u''
    # Ensure that the suffix is unicode. It's typically str/bytes because
    # units.py looks them up against str/bytes.
    elif isinstance(d.suffix, unicode):
      suffix = d.suffix
    else:
      suffix = d.suffix.decode('utf8')
    dims.append({
        'uom_suffix': suffix,
        'uom_code': d.code,
        'name': d.name,
    })
  # Refer to the module docstring for the expected schema.
  dimensioned_measured_value = measurement.measured_value
  value = (sorted(dimensioned_measured_value.value, key=lambda x: x[0])
           if dimensioned_measured_value.is_value_set else None)
  outcome_str = MEASUREMENT_OUTCOME_TO_TEST_RUN_STATUS_NAME[measurement.outcome]
  data = _convert_object_to_json({
      'outcome': outcome_str,
      'name': name,
      'dimensions': dims,
      'value': value,
  })
  attachment = htf_test_record.Attachment(data, test_runs_pb2.MULTIDIM_JSON)

  return attachment
953428
def to_dict(self):
        """"""
        return {
            'high': self.high,
            'low': self.low,
            'mean': self.mean,
            'count': self.count,
            'deviation': self.deviation,
        }
388007
def get_context_data(self, **kwargs):
        """"""
        data = super(MetricsListView, self).get_context_data(**kwargs)

        # Metrics organized by category, like so:
        # { <category_name>: [ <slug1>, <slug2>, ... ]}
        data.update({'metrics': get_r().metric_slugs_by_category()})
        return data
1293201
def get(self, deviceId):
        
        measurementsByName = self.measurements.get(deviceId)
        if measurementsByName is None:
            return []
        else:
            return list(measurementsByName.values())