Exemplo n.º 1
0
 def test_RDPG_sample(self):
     np.random.seed(8888)
     g = self.graph
     p_mat = self.p_mat
     estimator = RDPGEstimator(n_components=2)
     estimator.fit(g)
     _test_sample(estimator, p_mat, atol=0.2, n_samples=200)
Exemplo n.º 2
0
    def test_RDPG_score(self):
        p_mat = self.p_mat
        graph = self.graph
        estimator = RDPGEstimator()
        _test_score(estimator, p_mat, graph)

        with pytest.raises(ValueError):
            estimator.score_samples(graph=graph[1:100, 1:100])
Exemplo n.º 3
0
 def test_RDPG_nparams(self):
     n_verts = 1000
     g = self.graph
     e = RDPGEstimator(n_components=2)
     e.fit(g)
     assert e._n_parameters() == n_verts * 2
     g[100:, 50:] = 1
     e = RDPGEstimator(n_components=2)
     e.fit(g)
     assert e._n_parameters() == n_verts * 4
Exemplo n.º 4
0
    def test_RDPG_fit(self):
        np.random.seed(8888)
        n_points = 2000
        dists = np.random.uniform(0, 1, n_points)
        points = hardy_weinberg(dists)

        p_mat = points @ points.T
        p_mat -= np.diag(np.diag(p_mat))
        g = sample_edges(p_mat)

        estimator = RDPGEstimator(loops=False, n_components=3)
        estimator.fit(g)

        assert_allclose(estimator.p_mat_, p_mat, atol=0.2)
Exemplo n.º 5
0
    def test_RDPG_intputs(self):
        rdpge = RDPGEstimator()

        with pytest.raises(TypeError):
            RDPGEstimator(loops=6)

        with pytest.raises(ValueError):
            rdpge.fit(self.graph[:, :99])

        with pytest.raises(ValueError):
            rdpge.fit(self.graph[..., np.newaxis])

        with pytest.raises(TypeError):
            RDPGEstimator(ase_kws=5)

        with pytest.raises(TypeError):
            RDPGEstimator(diag_aug_weight="f")

        with pytest.raises(ValueError):
            RDPGEstimator(diag_aug_weight=-1)

        with pytest.raises(TypeError):
            RDPGEstimator(plus_c_weight="F")

        with pytest.raises(ValueError):
            RDPGEstimator(plus_c_weight=-1)