Create a wavefront compatible string representation of the metric value.

If the metric value is empty or not representable in wavefront, an empty
optional will be returned.
504186
public static Optional<String> wavefrontValue(MetricValue mv) {
        // Omit NaN and Inf.
        if (mv.isInfiniteOrNaN()) return Optional.empty();
        return mv.value().map(Number::toString);
    }
654302
private static void fillTLCValue2Edge(List<MetricInfo> componentMetrics, Map<String, TopologyEdge> edges) {
        String EDGE_DIM = "." + MetricDef.TUPLE_LIEF_CYCLE;
        for (MetricInfo info : componentMetrics) {
            if (info == null) continue;
            for (Map.Entry<String, Map<Integer, MetricSnapshot>> metric : info.get_metrics().entrySet()) {
                String name = metric.getKey();
                String[] split_name = name.split("@");
                String metricName = UIMetricUtils.extractMetricName(split_name);

                // only handle with `.TupleLifeCycle` metrics
                if (metricName == null || !metricName.contains(EDGE_DIM)) {
                    continue;
                }
                String componentId = UIMetricUtils.extractComponentName(split_name);
                String src = metricName.split("\\.")[0];
                String key = src + ":" + componentId;

                //get 60 window metric
                MetricSnapshot snapshot = metric.getValue().get(AsmWindow.M1_WINDOW);
                TopologyEdge edge = edges.get(key);
                if (edge != null) {
                    double value = snapshot.get_mean() / 1000;
                    edge.setCycleValue(value);
                    edge.appendTitle("TupleLifeCycle: " +
                            UIMetricUtils.format.format(value) + "ms");

                    for (Map.Entry<Integer, MetricSnapshot> winData : metric.getValue().entrySet()) {
                        // put the tuple life cycle time , unit is ms
                        double v = winData.getValue().get_mean() / 1000;
                        edge.putMapValue(MetricDef.TUPLE_LIEF_CYCLE + "(ms)", winData.getKey(),
                                UIMetricUtils.format.format(v));
                    }
                }
            }
        }
    }
815860
def _fmt_metric(value, show_stdv=True):
    """"""
    if len(value) == 2:
        return '%s:%g' % (value[0], value[1])
    if len(value) == 3:
        if show_stdv:
            return '%s:%g+%g' % (value[0], value[1], value[2])
        return '%s:%g' % (value[0], value[1])
    raise ValueError("wrong metric value")
617824
def toString(value, mode):
    
    string = angle.toString(value)
    sign = string[0]
    separator = CHAR[mode][sign]
    string = string.replace(':', separator, 1)
    return string[1:]
777016
@VisibleForTesting
  static Metric createMetric(
      io.opencensus.metrics.export.MetricDescriptor metricDescriptor,
      List<LabelValue> labelValues,
      String domain,
      Map<LabelKey, LabelValue> constantLabels) {
    Metric.Builder builder = Metric.newBuilder();
    builder.setType(generateType(metricDescriptor.getName(), domain));
    Map<String, String> stringTagMap = Maps.newHashMap();
    List<LabelKey> labelKeys = metricDescriptor.getLabelKeys();
    for (int i = 0; i < labelValues.size(); i++) {
      String value = labelValues.get(i).getValue();
      if (value == null) {
        continue;
      }
      stringTagMap.put(labelKeys.get(i).getKey(), value);
    }
    for (Map.Entry<LabelKey, LabelValue> constantLabel : constantLabels.entrySet()) {
      String constantLabelKey = constantLabel.getKey().getKey();
      String constantLabelValue = constantLabel.getValue().getValue();
      constantLabelValue = constantLabelValue == null ? "" : constantLabelValue;
      stringTagMap.put(constantLabelKey, constantLabelValue);
    }
    builder.putAllLabels(stringTagMap);
    return builder.build();
  }
6907
def to_s
      str = ''
      if @width > 0
        fmt = @width.truncate == @width ? '%d' : '%.2f'
        str << format(fmt, @width)
        str << '%' if @flag == PercentGeometry
      end

      str << 'x' if (@width > 0 && @flag != PercentGeometry) || (@height > 0)

      if @height > 0
        fmt = @height.truncate == @height ? '%d' : '%.2f'
        str << format(fmt, @height)
        str << '%' if @flag == PercentGeometry
      end
      str << format('%+d%+d', @x, @y) if @x != 0 || @y != 0
      str << FLAGS[@flag.to_i] if @flag != PercentGeometry
      str
    end
1230101
def validate_value_string (f, value_string):
    
    assert isinstance(f, Feature)
    assert isinstance(value_string, basestring)
    if f.free or value_string in f.values:
        return

    values = [value_string]

    if f.subfeatures:
        if not value_string in f.values and \
               not value_string in f.subfeatures:
            values = value_string.split('-')

    # An empty value is allowed for optional features
    if not values[0] in f.values and \
           (values[0] or not f.optional):
        raise InvalidValue ("'%s' is not a known value of feature '%s'\nlegal values: '%s'" % (values [0], f.name, f.values))

    for v in values [1:]:
        # this will validate any subfeature values in value-string
        implied_subfeature(f, v, values[0])
66165
function valueStrim(value, cutoff) {
        var strimLimit = typeof cutoff === 'undefined' ? 60 : cutoff;

        var t = typeof value;
        if (t === 'function') {
          return '[function]';
        }
        if (t === 'object') {
          value = JSON.stringify(value);
          if (value.length > strimLimit) {
            value = value.substr(0, strimLimit) + '...';
          }
          return value;
        }
        if (t === 'string') {
          if (value.length > strimLimit) {
            return JSON.stringify(value.substr(0, strimLimit)) + '...';
          }
          return JSON.stringify(value);
        }
        return '' + value;
      }
200666
private static Optional<Map.Entry<String, String>> createTagEntry(Map.Entry<String, MetricValue> tag_entry) {
        final Optional<String> opt_tag_value = tag_entry.getValue().asString();
        return opt_tag_value
                .map(tag_value -> SimpleMapEntry.create(name(tag_entry.getKey()), escapeTagValue(tag_value)));
    }
872469
def to_s(mode = nil)
      unit_string = unit.to_s(mode)
      if unit_string && unit_string != '1'
        "#{simplified_value} #{unit_string}"
      else
        simplified_value.to_s
      end
    end
295895
def to_toml(value, pretty=False):  # noqa: unused-argument
    

    if not toml:
        raise NotImplementedError('No supported TOML library available')

    return toml.dumps(make_toml_friendly(value)).rstrip()
680970
def to_string_with_default(value, default_value):
        
        result = StringConverter.to_nullable_string(value)
        return result if result != None else default_value
605412
def Record(self, value, fields=None):
    """"""
    key = _FieldsToKey(fields)
    metric_value = self._metric_values.get(key)
    if metric_value is None:
      metric_value = self._DefaultValue()
      self._metric_values[key] = metric_value
    metric_value.Record(value)
3022
def create_empty(cls, tstart, tstop, fill=0.0, nside=64):
        """"""
        cth_edges = np.linspace(0, 1.0, 41)
        domega = utils.edge_to_width(cth_edges) * 2.0 * np.pi
        hpx = HPX(nside, True, 'CEL', ebins=cth_edges)
        data = np.ones((len(cth_edges) - 1, hpx.npix)) * fill
        return cls(data, hpx, cth_edges, tstart=tstart, tstop=tstop)
30995
def stringify(self, value, **opts):
        
        if self._is_null(value):
            return None
        try:
            opts_ = self.opts.copy()
            opts_.update(opts)
            return self._stringify(value, **opts_)
        except Exception as e:
            if not isinstance(e, ConverterError):
                e = ConverterError(None, exc=e)
            e.converter = self.__class__
            raise e
570009
public static Stream<String> wavefrontLine(DateTime ts, TimeSeriesValue tsv) {
        final GroupName group = tsv.getGroup();

        return tsv.getMetrics().entrySet().stream()
                .flatMap(metricEntry -> wavefrontLineForMetric(ts, group, metricEntry));
    }
329148
function writeLineStringGeometry_(geometry) {
  if (geometry instanceof olGeomLineString) {
    const flatCoordinates = geometry.getFlatCoordinates();
    const stride = geometry.getStride();
    const end = flatCoordinates.length;
    return `l(${this.encodeCoordinates_(flatCoordinates, stride, 0, end)})`;
  }
  return null;
}