コード例 #1
0
    def test_n_pixels(self):
        persimgr = PersistenceImager(birth_range=(0, 5),
                                     pers_range=(0, 3),
                                     pixel_size=1)
        dgm = np.array([[0, 1], [1, 1], [3, 5]])
        img = persimgr.transform(dgm)

        np.testing.assert_equal(img.shape, (5, 3))

        img = persimgr.fit_transform(dgm)
        np.testing.assert_equal(img.shape, (3, 2))
コード例 #2
0
    def test_multiple_diagrams(self):
        persimgr = PersistenceImager(birth_range=(0, 5),
                                     pers_range=(0, 3),
                                     pixel_size=1)

        dgm1 = np.array([[0, 1], [1, 1], [3, 5]])
        dgm2 = np.array([[0, 1], [1, 1], [3, 6], [1, 1]])
        imgs = persimgr.transform([dgm1, dgm2])

        np.testing.assert_equal(len(imgs), 2)
        np.testing.assert_equal(imgs[0].shape, imgs[1].shape)

        imgs = persimgr.fit_transform([dgm1, dgm2])
        np.testing.assert_equal(len(imgs), 2)
        np.testing.assert_equal(imgs[0].shape, imgs[1].shape)
        np.testing.assert_equal(imgs[0].shape, (3, 3))