How to use the kmapper.visuals._map_val2color function in kmapper

To help you get started, we’ve selected a few kmapper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scikit-tda / kepler-mapper / test / test_visuals.py View on Github external
def test_map_val2color_on_point(self, default_colorscale):
        """ This function takes a val, a min and max, and a color scale, and finds the color the val should be """

        for v, color in default_colorscale:
            c = _map_val2color(v, 0.0, 1.0, default_colorscale)
            assert c == color
github scikit-tda / kepler-mapper / test / test_visuals.py View on Github external
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_function = np.array([0.55] * 10 + [0.0] * 10)
        member_ids = [1, 2, 3, 4, 5, 6]
        hist = build_histogram(color_function[member_ids])
        c = round(_color_function(member_ids, color_function), 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"]
github scikit-tda / kepler-mapper / test / test_visuals.py View on Github external
def test_mid_val2color(self, default_colorscale):
        expected = int((72 + 68) / 2), int((35 + 1) / 2), int((116 + 85) / 2)
        expected_str = (
            "rgb("
            + str(expected[0])
            + ", "
            + str(expected[1])
            + ", "
            + str(expected[2])
            + ")"
        )
        c = _map_val2color(0.05, 0.0, 1.0, default_colorscale)
        assert c == expected_str