Exemple #1
0
def generate_umami(dataframe, plot_metrics, highlight_index=-1, show_empty=False, show_invariant=False):
    """
    Generate a full UMAMI diagram based on an input dataframe and a list of
    column names.  Relies on abcutil.CONFIG to create labels and determine if
    big_is_good
    """
    umami = tokio.analysis.umami.Umami()
    for metric in plot_metrics:
        try:
            num_nans = sum(numpy.isnan(dataframe[metric]))
        except TypeError:
            num_nans = 0

        if (len(dataframe[metric].unique()) == 1) and (not show_invariant):
            warnings.warn("Skipping %s (no change in value)" % metric)
            continue

        if (len(dataframe[metric]) == num_nans) and (not show_empty):
            warnings.warn("Skipping %s (all values are NaN)" % metric)
            continue

        label = abcutils.CONFIG['metric_labels'].get(metric, metric)
        big_is_good = abcutils.CONFIG['metric_big_is_good'].get(metric, True)
        umami[metric] = tokio.analysis.umami.UmamiMetric(
            timestamps=dataframe['_datetime_start'],
            values=dataframe[metric],
            label=label,
            big_is_good=big_is_good)

    return umami.plot(highlight_index=highlight_index)
def test_umami_plot_to_file():
    """
    Ensure that basic UMAMI plot can be generated
    """
    umami = build_umami_from_sample()
    fig = umami.plot(output_file=tokiotest.TEMP_FILE.name)
    print "Wrote output to %s" % tokiotest.TEMP_FILE.name
    verify_umami_fig(fig)
Exemple #3
0
def test_umami_plot_uneven_data():
    """
    Ensure that basic UMAMI plot can be generated with uneven data
    """
    umami = build_umami_from_sample(datasets=SAMPLE_DATA_UNEVEN)
    fig = umami.plot(output_file=tokiotest.TEMP_FILE.name)
    print("Wrote output to %s" % tokiotest.TEMP_FILE.name)
    verify_umami_fig(fig, datasets=SAMPLE_DATA_UNEVEN)
def test_umamimetric_append():
    """
    UmamiMetric append functionality
    """
    umami_metrics = []
    for index, sample_data in enumerate(SAMPLE_DATA):
        umami_metric = tokio.analysis.umami.UmamiMetric(
            timestamps=[],
            values=[],
            label="Test Metric %d" % index,
            big_is_good=True)
        print "%d: sample_data is %d units long (%s)" % (
            index, len(sample_data), json.dumps(sample_data))
        for jndex, sample_datum in enumerate(sample_data):
            umami_metric.append(SAMPLE_TIMES[jndex], sample_datum)
        umami_metrics.append(umami_metric)

    umami = tokio.analysis.umami.Umami()
    for index, umami_metric in enumerate(umami_metrics):
        umami["test_metric_%d" % index] = umami_metric

    fig = umami.plot()
    verify_umami_fig(fig)