How to use the ripser.plot_dgms function in ripser

To help you get started, we’ve selected a few ripser 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 / ripser.py / test / test_visuals.py View on Github external
def test_single(self):
        """ Most just test this doesn't crash
        """
        diagram = np.array([[0, 1], [1, 1], [2, 4], [3, 5]])

        f, ax = plt.subplots()
        plot_dgms(diagram, show=False)

        x_plot, y_plot = ax.lines[0].get_xydata().T

        assert x_plot[0] <= np.min(diagram)
        assert x_plot[1] >= np.max(diagram)

        # get PathCollection
        pathcols = [child for child in ax.get_children()
                    if child.__class__.__name__ == "PathCollection"]
        assert len(pathcols) == 1
github scikit-tda / ripser.py / test / test_visuals.py View on Github external
def test_show(self):
        diagrams = [
            np.array([[0, 1], [1, 1], [2, 4], [3, 5]]),
            np.array([[0.5, 3], [2, 4], [4, 5], [10, 15]])
        ]
        f, ax = plt.subplots()
        plot_dgms(diagrams, legend=False, show=True)
github scikit-tda / ripser.py / test / test_visuals.py View on Github external
def test_lifetime(self):
        diagrams = [
            np.array([[0, 1], [1, 1], [2, 4], [3, 5]]),
            np.array([[0.5, 3], [2, 4], [4, 5], [10, 15]])
        ]

        f, ax = plt.subplots()
        plot_dgms(diagrams, lifetime=True, show=False)

        assert ax.get_ylabel() == 'Lifetime'
        assert ax.get_xlabel() == 'Birth'

        line = ax.get_lines()[0]
        np.testing.assert_array_equal(line.get_ydata(), [0, 0])
github scikit-tda / ripser.py / test / test_visuals.py View on Github external
def test_infty(self):
        diagrams = [
            np.array([[0, np.inf], [1, 1], [2, 4], [3, 5]]),
            np.array([[0.5, 3], [2, 4], [4, 5], [10, 15]])
        ]

        f, ax = plt.subplots()
        plot_dgms(diagrams, legend=True, show=False)
github scikit-tda / ripser.py / test / test_visuals.py View on Github external
def test_default_square(self):
        diagrams = [
            np.array([[0, 1], [1, 1], [2, 4], [3, 5]]),
            np.array([[0.5, 3], [2, 4], [4, 5], [10, 15]])
        ]

        f, ax = plt.subplots()
        plot_dgms(diagrams, show=False)
        diagonal = ax.lines[0].get_xydata()

        assert diagonal[0, 0] == diagonal[0, 1]
        assert diagonal[1, 0] == diagonal[1, 1]
github scikit-tda / ripser.py / test / test_visuals.py View on Github external
def test_legend_false(self):
        diagrams = [
            np.array([[0, 1], [1, 1], [2, 4], [3, 5]]),
            np.array([[0.5, 3], [2, 4], [4, 5], [10, 15]])
        ]

        f, ax = plt.subplots()
        plot_dgms(diagrams, legend=False, show=False)
        legend = [child for child in ax.get_children()
                  if child.__class__.__name__ == "Legend"]

        assert len(legend) == 0
github scikit-tda / ripser.py / test / test_visuals.py View on Github external
def test_default_label(self):
        diagrams = [
            np.array([[0, 1], [1, 1], [2, 4], [3, 5]]),
            np.array([[0.5, 3], [2, 4], [4, 5], [10, 15]])
        ]

        f, ax = plt.subplots()
        plot_dgms(diagrams, show=False)

        assert ax.get_ylabel() == 'Death'
        assert ax.get_xlabel() == 'Birth'
github scikit-tda / ripser.py / test / test_visuals.py View on Github external
def test_set_title(self):
        diagrams = [
            np.array([[0, 1], [1, 1], [2, 4], [3, 5]]),
            np.array([[0.5, 3], [2, 4], [4, 5], [10, 15]])
        ]

        f, ax = plt.subplots()
        plot_dgms(diagrams, title='my title', show=False)
        assert ax.get_title() == 'my title'

        f, ax = plt.subplots()
        plot_dgms(diagrams, show=False)
        assert ax.get_title() == ''
github scikit-tda / ripser.py / test / test_visuals.py View on Github external
def test_lifetime_removes_birth(self):
        diagrams = [
            np.array([[0, 1], [1, 1], [2, 4], [3, 5]]),
            np.array([[0.5, 3], [2, 4], [4, 5], [10, 15]])
        ]

        f, ax = plt.subplots()
        plot_dgms(diagrams, lifetime=True, show=False)

        pathcols = [child for child in ax.get_children()
                    if child.__class__.__name__ == "PathCollection"]

        modded1 = diagrams[0]
        modded1[:, 1] = diagrams[0][:, 1] - diagrams[0][:, 0]
        modded2 = diagrams[1]
        modded2[:, 1] = diagrams[1][:, 1] - diagrams[1][:, 0]
        assert len(pathcols) == 2
        np.testing.assert_array_equal(pathcols[0].get_offsets(), modded1)
        np.testing.assert_array_equal(pathcols[1].get_offsets(), modded2)
github scikit-tda / cechmate / PhatCech.py View on Github external
def testAlpha():
    from ripser import plot_dgms
    # Make a 3-sphere in 4 dimensions
    X = np.random.randn(200, 4)
    X = X/np.sqrt(np.sum(X**2, 1)[:, None])
    tic = time.time()
    dgms = alpha_filtration(X)
    phattime = time.time() - tic
    print("Elapsed Time: %.3g"%phattime)
    plot_dgms([dgms[i] for i in range(len(dgms))])
    plt.show()

ripser

A Lean Persistent Homology Library for Python

MIT
Latest version published 4 months ago

Package Health Score

75 / 100
Full package analysis

Similar packages