def test_average_sensitivity_c_elegans(self): from neet.boolean.examples import c_elegans s = average_sensitivity(c_elegans) self.assertAlmostEqual(s, 1.265625) s = average_sensitivity(c_elegans, states=[[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1]], weights=[9, 1]) self.assertAlmostEqual(s, 1.7)
def test_average_sensitivity_logic_network(self): net = NB.LogicNetwork([((1, 2), {'01', '10'}), ((0, 2), ('01', '10', '11')), ((0, 1), {'11'})]) s = average_sensitivity(net) self.assertAlmostEqual(s, 1.3333333333333333) s = average_sensitivity(net, weights=np.ones(8)) self.assertAlmostEqual(s, 1.3333333333333333) s = average_sensitivity(net, states=net.state_space()) self.assertAlmostEqual(s, 1.3333333333333333)
def test_average_sensitivity_lengths(self): net = NB.WTNetwork([[1, -1], [0, 1]], [0.5, 0]) with self.assertRaises(ValueError): average_sensitivity( net, states=[[0, 0], [0, 1]], weights=[0, 1, 2])
def test_average_sensitivity(self): net = NB.WTNetwork([[1, -1], [0, 1]], [0.5, 0]) self.assertEqual(1.0, average_sensitivity(net))
def test_average_sensitivity_net_type(self): with self.assertRaises(TypeError): average_sensitivity(self.IsNotNetwork()) with self.assertRaises(TypeError): average_sensitivity(self.IsNotBooleanNetwork())