How to use the persim.bottleneck function in persim

To help you get started, we’ve selected a few persim 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 / persim / test / test_visuals.py View on Github external
def test_plot_labels(self):
        dgm1 = np.array([
            [0.1, 0.2],
            [0.2, 0.4]
        ])
        dgm2 = np.array([
            [0.1, 0.2],
            [0.3, 0.45]
        ])

        d, (matching, D) = persim.bottleneck(dgm1, dgm2, matching=True)
        persim.bottleneck_matching(
            dgm1, dgm2, matching, D, labels=["X", "Y"])
github scikit-tda / persim / test / test_distances.py View on Github external
def test_matching(self):
        dgm1 = np.array([
            [0.5, 1],
            [0.6, 1.1]
        ])
        dgm2 =  np.array([
            [0.5, 1.1],
            [0.6, 1.1],
            [0.8, 1.1],
            [1.0, 1.1],
        ])

        d, (m, D) = bottleneck(
            dgm1, dgm2,
            matching=True
        )

        # These are very loose bounds
        assert len(m) == len(dgm1) + len(dgm2)
        assert D.shape  == (len(dgm1) + len(dgm2), len(dgm1) + len(dgm2))
github scikit-tda / persim / test / test_distances.py View on Github external
def test_single(self):
        d = bottleneck(
            np.array([[0.5, 1]]),
            np.array([[0.5, 1.1]])
        )

        # These are very loose bounds
        assert d == pytest.approx(0.1, 0.001)
github scikit-tda / persim / test / test_visuals.py View on Github external
def test_bottleneck_matching(self):
        dgm1 = np.array([
            [0.1, 0.2],
            [0.2, 0.4]
        ])
        dgm2 = np.array([
            [0.1, 0.2],
            [0.3, 0.45]
        ])

        d, (matching, D) = persim.bottleneck(dgm1, dgm2, matching=True)
        persim.bottleneck_matching(dgm1, dgm2, matching, D)
github scikit-tda / persim / test / test_distances.py View on Github external
def test_different_size(self):
        d = bottleneck(
            np.array([
                [0.5, 1],
                [0.6, 1.1]
            ]),
            np.array([
                [0.5, 1.1]
            ])
        )

        # These are very loose bounds
        assert d == pytest.approx(0.1, 0.001)
github scikit-tda / persim / test / test_distances.py View on Github external
def test_some(self):
        d = bottleneck(
            np.array([
                [0.5, 1],
                [0.6, 1.1]
            ]),
            np.array([
                [0.5, 1.1],
                [0.6, 1.3]
            ])
        )

        # These are very loose bounds
        assert d == pytest.approx(0.2, 0.001)
github scikit-tda / persim / test / test_distances.py View on Github external
def test_diagonal(self):
        d = bottleneck(
            np.array([
                [10.5, 10.5],
                [10.6, 10.5],
                [10.3, 10.3]
            ]),
            np.array([
                [0.5, 1.0],
                [0.6, 1.2],
                [0.3, 0.7]
            ])
        )

        # I expect this to be 0.6
        assert d == pytest.approx(0.3, 0.001)