Esempio n. 1
0
 def test_sampling_invalid_changepoints(self):
     DGS = DynamicGraphicalModel(5)
     n_edges_list = [2, 4, 1]
     changepoints = [5]
     DGS.generate_graphs(n_edges_list)
     with self.assertRaises(ValueError):
         DGS.sample(10, changepoints)
Esempio n. 2
0
 def test_changepoint_return(self):
     n_verts, n_edges, T = 4, 3, 15
     n_edges_list = [2, 4, 1]
     DGS = DynamicGraphicalModel(n_verts, seed=7)
     DGS.generate_graphs(n_edges_list)
     S, cps = DGS.sample(T, ret_cps=True)
     self.assertEqual(len(cps), len(n_edges_list)-1)
Esempio n. 3
0
 def test_sample_format(self):
     n_verts, n_edges, T = 4, 3, 15
     n_edges_list = [2, 4, 1]
     DGS = DynamicGraphicalModel(n_verts, seed=7)
     DGS.generate_graphs(n_edges_list)
     S = DGS.sample(T)
     self.assertEqual(S.shape, (T, n_verts))
Esempio n. 4
0
 def test_sampling_wo_seed(self):
     n_verts, n_edges = 4, 3
     n_edges_list = [2, 4, 1]
     DGS = DynamicGraphicalModel(n_verts, seed=7)
     DGS.generate_graphs(n_edges_list)
     sample1 = DGS.sample(10, use_seed=False)
     sample2 = DGS.sample(10, use_seed=False)
     self.assertTrue(~np.allclose(sample1, sample2))
Esempio n. 5
0
 def test_sampling_no_changepoints(self):
     DGS = DynamicGraphicalModel(5)
     n_edges_list = [2, 4, 1]
     DGS.generate_graphs(n_edges_list)
     with self.assertRaises(ValueError):
         DGS.sample(10, uniform=False)
Esempio n. 6
0
 def test_sampling_too_short(self):
     DGS = DynamicGraphicalModel(5)
     n_edges_list = [2, 4, 1]
     DGS.generate_graphs(n_edges_list)
     with self.assertRaises(ValueError):
         DGS.sample(len(n_edges_list) - 1)
Esempio n. 7
0
 def test_sampling_wo_graph(self):
     DGS = DynamicGraphicalModel(5)
     with self.assertRaises(RuntimeError):
         DGS.sample(10)