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)
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)
def test_zero_order_deg_eq(self): n = Network(edges=self.first_order_deg) self.assertEqual(n.nodes['A'].equation, '-k0*A')
def test_zero_order_prod_eq(self): n = Network(edges=self.zero_order_prod) self.assertEqual(n.nodes['B'].equation, '+k0')
def test_first_order_transition_eq(self): n = Network(edges=self.first_order_transition) self.assertEqual(n.nodes['A'].equation, '-k0*A')
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)
def test_zeroth_order(self): n = Network(self.tsg) out = n.zeroth_order('parameter1') self.assertTrue(str(out) == 'parameter1')
def test_second_order_transition_eq4(self): n = Network(edges=self.second_order_transition) self.assertEqual(n.nodes['D'].equation, '+k0*A*B')
def test_parameter_list(self): n = Network(edges=[self.second_order_deg, self.first_order_transition]) self.assertEqual(n.parameter_list, 'k0 k1'.split())
def test_edge4(self): n = Network(self.tsg) # print(n.new_innovation()) n.random_edge(0)
def test_node_factory(self): n = Network(self.tsg) self.assertTrue(n.node_factory() == 'N3')
def test_parameter_factory(self): n = Network(self.tsg) self.assertTrue(n.parameter_factory() == 'k1')
def test_select_node(self): n = Network(self.tsg) nodes = sorted(n.select_node(2)) self.assertTrue(nodes == [0, 1])
def test_second_order(self): n = Network(self.tsg) out = n.second_order('parameter1', 'species1', 'species2') self.assertTrue(str(out) == 'parameter1*species1*species2')
def test_first_order(self): n = Network(self.tsg) out = n.first_order('parameter1', 'species1') self.assertTrue(str(out) == 'parameter1*species1')
def test_complex_break_eq3(self): n = Network(edges=self.complex_break) self.assertEqual(n.nodes['C'].equation, '+k0*A')
def test_complex_form_eq3(self): n = Network(edges=self.complex_form) self.assertEqual(n.nodes['C'].equation, '+k0*A*B')
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)
def test_second_order_deg_eq1(self): n = Network(edges=self.second_order_deg) self.assertEqual(n.nodes['A'].equation, '-k0*A*B')
def test_select_sign(self): n = Network(self.tsg) sign = n.select_sign() self.assertTrue(sign in ['-', '+'])