Пример #1
0
 def test_sample_parameters(self):
     numpy.random.seed(1)
     n = Network(edges=[
         self.second_order_deg, self.first_order_transition,
         self.zero_order_prod
     ])
     params = sorted([i for i in n.parameter_sampling().values()])
     vals = sorted(
         [-0.331911981189704, 0.8812979737686324, -1.9995425007306205])
     self.assertListEqual(params, vals)
Пример #2
0
 def test_infer_nodes2(self):
     n = Network(edges=[
         self.first_order_deg, self.zero_order_prod,
         self.second_order_transition
     ])
     nodes = ['A', 'B', 'C', 'D']
     self.assertListEqual(sorted([i for i in n.nodes.keys()]), nodes)
Пример #3
0
 def test_zero_order_deg_eq(self):
     n = Network(edges=self.first_order_deg)
     self.assertEqual(n.nodes['A'].equation, '-k0*A')
Пример #4
0
 def test_zero_order_prod_eq(self):
     n = Network(edges=self.zero_order_prod)
     self.assertEqual(n.nodes['B'].equation, '+k0')
Пример #5
0
 def test_first_order_transition_eq(self):
     n = Network(edges=self.first_order_transition)
     self.assertEqual(n.nodes['A'].equation, '-k0*A')
Пример #6
0
 def test_infer_nodes(self):
     n = Network(edges=[self.first_order_deg, self.zero_order_prod])
     nodes = ['A', 'B']
     self.assertListEqual(sorted([i for i in n.nodes.keys()]), nodes)
Пример #7
0
 def test_zeroth_order(self):
     n = Network(self.tsg)
     out = n.zeroth_order('parameter1')
     self.assertTrue(str(out) == 'parameter1')
Пример #8
0
 def test_second_order_transition_eq4(self):
     n = Network(edges=self.second_order_transition)
     self.assertEqual(n.nodes['D'].equation, '+k0*A*B')
Пример #9
0
 def test_parameter_list(self):
     n = Network(edges=[self.second_order_deg, self.first_order_transition])
     self.assertEqual(n.parameter_list, 'k0 k1'.split())
Пример #10
0
 def test_edge4(self):
     n = Network(self.tsg)
     # print(n.new_innovation())
     n.random_edge(0)
Пример #11
0
 def test_node_factory(self):
     n = Network(self.tsg)
     self.assertTrue(n.node_factory() == 'N3')
Пример #12
0
 def test_parameter_factory(self):
     n = Network(self.tsg)
     self.assertTrue(n.parameter_factory() == 'k1')
Пример #13
0
    def test_select_node(self):
        n = Network(self.tsg)
        nodes = sorted(n.select_node(2))

        self.assertTrue(nodes == [0, 1])
Пример #14
0
 def test_second_order(self):
     n = Network(self.tsg)
     out = n.second_order('parameter1', 'species1', 'species2')
     self.assertTrue(str(out) == 'parameter1*species1*species2')
Пример #15
0
 def test_first_order(self):
     n = Network(self.tsg)
     out = n.first_order('parameter1', 'species1')
     self.assertTrue(str(out) == 'parameter1*species1')
Пример #16
0
 def test_complex_break_eq3(self):
     n = Network(edges=self.complex_break)
     self.assertEqual(n.nodes['C'].equation, '+k0*A')
Пример #17
0
 def test_complex_form_eq3(self):
     n = Network(edges=self.complex_form)
     self.assertEqual(n.nodes['C'].equation, '+k0*A*B')
Пример #18
0
 def test_solve(self):
     n = Network(edges=[self.first_order_transition])
     print(n.ode)
     ic = {'A': 10, 'B': 0}
     params = {'k0': 0.1}
     n.solve(ic, params)
Пример #19
0
 def test_second_order_deg_eq1(self):
     n = Network(edges=self.second_order_deg)
     self.assertEqual(n.nodes['A'].equation, '-k0*A*B')
Пример #20
0
 def test_select_sign(self):
     n = Network(self.tsg)
     sign = n.select_sign()
     self.assertTrue(sign in ['-', '+'])