Ejemplo n.º 1
0
def graph_data_distribution(graph, color_function, colorscale, nbins=10):

    node_averages = []
    for node_id, member_ids in graph["nodes"].items():
        member_colors = color_function[member_ids]
        node_averages.append(np.mean(member_colors))

    histogram = build_histogram(node_averages,
                                colorscale=colorscale,
                                nbins=nbins)

    return histogram
Ejemplo n.º 2
0
    def test_color_hist_matches_nodes(self):
        """ The histogram colors dont seem to match the node colors, this should confirm the colors will match and we need to look at the javascript instead.
        """

        color_values = np.array([0.55] * 10 + [0.0] * 10)
        member_ids = [1, 2, 3, 4, 5, 6]
        hist = build_histogram(color_values[member_ids])
        c = round(_node_color_function(member_ids, color_values), 2)
        single_bar = [bar for bar in hist if bar["perc"] == 100.0]

        assert len(single_bar) == 1
        assert _map_val2color(c, 0.0, 1.0) == single_bar[0]["color"]
Ejemplo n.º 3
0
def _tooltip_components(
    member_ids,
    X,
    X_names,
    lens,
    lens_names,
    color_function,
    node_ID,
    colorscale,
    nbins=10,
):
    projection_stats = km.visuals._format_projection_statistics(
        member_ids, lens, lens_names)
    cluster_stats = km.visuals._format_cluster_statistics(
        member_ids, X, X_names)

    member_histogram = build_histogram(color_function[member_ids],
                                       colorscale=colorscale,
                                       nbins=nbins)

    return projection_stats, cluster_stats, member_histogram
Ejemplo n.º 4
0
 def test_histogram(self):
     data = np.random.random((100, 1))
     hist = visuals.build_histogram(data)
     assert isinstance(hist, list)
     assert isinstance(hist[0], dict)
     assert len(hist) == 10