How to use ripser - 10 common examples

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_ripser_sklearn.py View on Github external
def test_verbose_false(self):
        data = np.array([[0.0, 0.0], [10.0, 0.0], [10.0, 10.0], [0.0, 10.0]])
        rips = Rips(verbose=False)
        dgm = rips.fit_transform(data)
        assert dgm[0].shape == (4,2)
        assert dgm[1].shape == (1,2)
github scikit-tda / ripser.py / test / test_ripser_sklearn.py View on Github external
def test_maxdim(self):
        np.random.seed(3100)
        data = np.random.random((100, 3))

        # maxdim refers to the max H_p class, generate all less than

        rips0 = Rips(maxdim=0)
        dgm0 = rips0.fit_transform(data)
        assert len(dgm0) == 1

        rips1 = Rips(maxdim=1)
        dgm1 = rips1.fit_transform(data)
        assert len(dgm1) == 2

        rips2 = Rips(maxdim=2)
        dgm2 = rips2.fit_transform(data)
        assert len(dgm2) == 3
github scikit-tda / ripser.py / test / test_ripser_sklearn.py View on Github external
def test_defaults(self):
        data = np.random.random((100, 3))

        rips = Rips()
        dgm = rips.fit_transform(data)

        assert len(dgm) == 2
        assert rips.coeff == 2
github scikit-tda / ripser.py / test / test_ripser_sklearn.py View on Github external
def test_thresh(self):
        np.random.seed(3100)
        data = np.random.random((100, 3))

        rips0 = Rips(thresh=0.1)
        dgm0 = rips0.fit_transform(data)

        rips1 = Rips(thresh=1)
        dgm1 = rips1.fit_transform(data)

        # Barcode of H_1 diagram will be smaller, right?
        assert len(dgm0[1]) < len(dgm1[1]), "Usually"
github scikit-tda / ripser.py / test / test_ripser_sklearn.py View on Github external
def test_instantiate(self):
        rip = Rips()
        assert rip is not None
github scikit-tda / ripser.py / test / test_ripser_sklearn.py View on Github external
def test_maxdim(self):
        np.random.seed(3100)
        data = np.random.random((100, 3))

        # maxdim refers to the max H_p class, generate all less than

        rips0 = Rips(maxdim=0)
        dgm0 = rips0.fit_transform(data)
        assert len(dgm0) == 1

        rips1 = Rips(maxdim=1)
        dgm1 = rips1.fit_transform(data)
        assert len(dgm1) == 2

        rips2 = Rips(maxdim=2)
        dgm2 = rips2.fit_transform(data)
        assert len(dgm2) == 3
github scikit-tda / ripser.py / test / test_ripser_sklearn.py View on Github external
def test_sparse(self):
        np.random.seed(10)
        thresh = 1.1

        # Do dense filtration with threshold
        data = datasets.make_circles(n_samples=100)[
            0] + 5 * datasets.make_circles(n_samples=100)[0]
        rips0 = Rips(thresh=thresh, maxdim=1)
        dgms0 = rips0.fit_transform(data)

        # Convert to sparse matrix first based on threshold,
        # then do full filtration
        rips1 = Rips(maxdim=1)
        D = makeSparseDM(data, thresh)
        dgms1 = rips1.fit_transform(D, distance_matrix=True)

        # The same number of edges should have been added
        assert rips0.num_edges_ == rips1.num_edges_

        I10 = dgms0[1]
        I11 = dgms1[1]
        idx = np.argsort(I10[:, 0])
        I10 = I10[idx, :]
        idx = np.argsort(I11[:, 0])
        I11 = I11[idx, :]
        assert np.allclose(I10, I11)
github scikit-tda / ripser.py / test / test_ripser_sklearn.py View on Github external
def test_input_warnings(self):

        rips = Rips()
        data = np.random.random((3, 10))

        with pytest.warns(UserWarning, match='has more columns than rows') as w:
            rips.transform(data)

        data = np.random.random((3, 3))
        with pytest.warns(UserWarning, match='input matrix is square, but the distance_matrix') as w:
            rips.transform(data)
github scikit-tda / ripser.py / test / test_ripser_sklearn.py View on Github external
def test_non_square_dist_matrix(self):
        
        rips = Rips()
        data = np.random.random((3, 10))

        with pytest.raises(Exception):
            rips.transform(data, distance_matrix=True)
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

ripser

A Lean Persistent Homology Library for Python

MIT
Latest version published 2 months ago

Package Health Score

75 / 100
Full package analysis

Similar packages