def test_inv_diagonal(self): precalculated_result = -0.333 confusion_matrix = np.full((4,4), 5) np.fill_diagonal(confusion_matrix, 0) result = catcorr.rk_coeff_np(confusion_matrix) difference = abs(precalculated_result - result) self.assertLess(difference, 0.001)
def test_col(self): confusion_matrix = np.zeros((4,4)) confusion_matrix[:,1] = [15,15,15,15] result = catcorr.rk_coeff_np(confusion_matrix) self.assertEqual(result, 0)
def test_arange_2(self): precalculated_result = -0.031676277618 arange = np.arange(16, dtype=np.float).reshape((4,4)) result = catcorr.rk_coeff_np(arange) difference = abs(precalculated_result - result) self.assertLess(difference, 1e-08)
def test_large_table(self): large_table = np.ones((500, 500)) result = catcorr.rk_coeff_np(large_table) self.assertEqual(result, 0)
def test_arange(self): precalculated_result = -0.07007127538 arange = np.arange(9).reshape((3,3)) result = catcorr.rk_coeff_np(arange) difference = abs(precalculated_result - result) self.assertLess(difference, 1e-08)
def test_diag_ones(self): diag_ones = np.eye(7) result = catcorr.rk_coeff_np(diag_ones) self.assertEqual(result, 1)
def test_ones(self): ones = np.ones((4, 4)) result = catcorr.rk_coeff_np(ones) self.assertEqual(result, 0)
def test_zeros(self): zeros = np.zeros((4, 4)) result = catcorr.rk_coeff_np(zeros) self.assertEqual(result, 0)