def test_values(self): # uniform histogram self.assertTrue(_entropy([1, 1, 1]) == np.log2(3)) # use the examples of the TestErrorHistogramHelperFunction test above # A) hist = [0, 4] self.assertTrue(_entropy(hist) == 0) # B) hist = [0, 0, 4, 0] self.assertTrue(_entropy(hist) == 0) # C) hist = [4, 0, 0, 0] self.assertTrue(_entropy(hist) == 0) # D) hist = [0, 0, 3, 1] self.assertTrue(np.allclose(_entropy(hist), 0.811278124459)) # E) hist = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 8, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] self.assertTrue(np.allclose(_entropy(hist), 0.921928094887))
def test_values(self): # uniform histogram self.assertTrue(_entropy([1, 1, 1]) == np.log2(3)) # use the examples of the TestErrorHistogramHelperFunction test above # A) hist = [0, 4] self.assertTrue(_entropy(hist) == 0) # B) hist = [0, 0, 4, 0] self.assertTrue(_entropy(hist) == 0) # C) hist = [4, 0, 0, 0] self.assertTrue(_entropy(hist) == 0) # D) hist = [0, 0, 3, 1] self.assertTrue(np.allclose(_entropy(hist), 0.811278124459)) # E) hist = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 8, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] self.assertTrue(np.allclose(_entropy(hist), 0.921928094887))
def test_types(self): entropy = _entropy(np.ones(6)) self.assertIsInstance(entropy, float)