def test_theoretical_output(self):
        """
        proper_value is calculated using R function infotheo::condentropy(method="emp")
        """
        input_1 = [9, 8, 7, 6, 5, 4, 3, 2, 9]
        cond_1 = [1, 1, 1, 1, 0, 0, 0, 0, 0]
        proper_value_1 = 1.510263
        self.assertAlmostEqual(conditional_entropy(input_1, cond_1),
                               proper_value_1,
                               places=3)

        input_2 = [0, 0, 0, 0, 1, 0, 0, 0, 0]
        cond_2 = [1, 1, 1, 1, 0, 0, 0, 0, 0]
        proper_value_2 = 0.2780013
        self.assertAlmostEqual(conditional_entropy(input_2, cond_2),
                               proper_value_2,
                               places=3)

        # Entropy must be higher in more diverse vectors
        self.assertGreater(conditional_entropy(input_1, cond_1),
                           conditional_entropy(input_2, cond_2))
 def test_nparray_input(self):
     np_input = np.array([1, 2, 3, 5, 432, 42, 31234, 342, 34])
     condition = np.array([1, 1, 1, 1, 0, 0, 0, 0, 0])
     self.assertIsInstance(conditional_entropy(np_input, condition), float)
 def test_list_input(self):
     list_input = [1, 2, 3, 5, 432, 42, 31234, 342, 34]
     condition = [1, 1, 1, 1, 0, 0, 0, 0, 0]
     self.assertIsInstance(conditional_entropy(list_input, condition),
                           float)
 def test_different_input_sizes(self):
     input = [0, 1]
     condition = [1, 2, 3]
     with self.assertRaises(AssertionError):
         conditional_entropy(input, condition)
 def test_one_number_input(self):
     self.assertEqual(conditional_entropy([1], [0]), 0.0)
 def test_empty_input(self):
     input = []
     condition = []
     with self.assertRaises(AssertionError):
         conditional_entropy(input, condition)