Esempio n. 1
0
 def test_expected_returns_logic_or(self):
     nt = Network()
     nt.i = np.array([0, 0])
     self.assertEqual(nt.expected(), 0)
     nt.i = np.array([1, 0])
     self.assertEqual(nt.expected(), 1)
     nt.i = np.array([0, 1])
     self.assertEqual(nt.expected(), 1)
     nt.i = np.array([1, 1])
     self.assertEqual(nt.expected(), 1)
Esempio n. 2
0
 def test_expected_requires_ndarray_with_0s_or_1s_for_i(self):
     nt = Network()
     nt.i = np.array([
         1,
         2,
     ])
     regex = 'The values should be either 0 or 1'
     with self.assertRaisesRegex(ValueError, regex):
         nt.expected()
Esempio n. 3
0
 def test_expected_requires_ndarray_len_2_for_i(self):
     nt = Network()
     nt.i = np.array([
         1,
         2,
         3,
     ])
     regex = 'The length should be 2.'
     with self.assertRaisesRegex(ValueError, regex):
         nt.expected()
Esempio n. 4
0
 def test_expected_requires_ndarray_for_i(self):
     nt = Network()
     nt.i = 'void'
     regex = 'A numpy ndarray was expected.'
     with self.assertRaisesRegex(TypeError, regex):
         nt.expected()