Пример #1
0
    def test_DCER_inputs(self):
        with pytest.raises(TypeError):
            DCEREstimator(directed="hey")

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

        graph = er_np(100, 0.5)
        dcere = DCEREstimator()

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

        with pytest.raises(ValueError):
            dcere.fit(graph[..., np.newaxis])
Пример #2
0
    def test_DCER_sample(self):
        np.random.seed(8888)
        estimator = DCEREstimator(directed=True, loops=False)
        g = self.graph
        p_mat = self.p_mat
        with pytest.raises(NotFittedError):
            estimator.sample()

        estimator.fit(g)
        with pytest.raises(ValueError):
            estimator.sample(n_samples=-1)

        with pytest.raises(TypeError):
            estimator.sample(n_samples="nope")
        B = 0.5
        dc = np.random.uniform(0.25, 0.75, size=100)
        p_mat = np.outer(dc, dc) * B
        p_mat -= np.diag(np.diag(p_mat))
        g = sample_edges(p_mat, directed=True)
        estimator.fit(g)
        estimator.p_mat_ = p_mat
        _test_sample(estimator, p_mat, n_samples=1000, atol=0.2)
Пример #3
0
 def test_DCER_nparams(self):
     n_verts = 1000
     graph = self.graph
     e = DCEREstimator(directed=True)
     e.fit(graph)
     assert e._n_parameters() == (n_verts + 1)