def test_labels_count_no_valid_observations(self): annotations = [ [MV, MV], [MV, MV], ] with self.assertRaises(voting.PyannoValueError): voting.labels_count([], 3) with self.assertRaises(voting.PyannoValueError): voting.labels_count(annotations, 3)
def test_labels_count(self): annotations = [ [1, 2, MV, MV], [MV, MV, 3, 3], [MV, 1, 3, 1], [MV, MV, MV, MV], ] nclasses = 5 expected = [0, 3, 1, 3, 0] result = voting.labels_count(annotations, nclasses) self.assertEqual(result, expected)
def test_labels_count(): annotations = [ [1, 2, MV, MV], [MV, MV, 3, 3], [MV, 1, 3, 1], [MV, MV, MV, MV], ] nclasses = 5 expected = [0, 3, 1, 3, 0] result = voting.labels_count(annotations, nclasses) assert result == expected
def test_labels_count_newmissingvalue(self): m = -99 annotations = [ [1, 2, m, m], [m, m, 3, 3], [m, 1, 3, 1], [m, m, m, m], ] nclasses = 5 expected = [0, 3, 1, 3, 0] result = voting.labels_count(annotations, nclasses, m) self.assertEqual(result, expected)
def test_labels_count_newmv(self): mv = -999 annotations = [ [1, 2, mv, mv], [mv, mv, 3, 3], [mv, 1, 3, 1], [mv, mv, mv, mv], ] nclasses = 5 expected = [0, 3, 1, 3, 0] result = voting.labels_count(annotations, nclasses, missing_value=mv) self.assertEqual(result, expected)
def test_labels_count_non_default_missing_values(): mv = -999 annotations = [ [ 1, 2, mv, mv], [mv, mv, 3, 3], [mv, 1, 3, 1], [mv, mv, mv, mv], ] nclasses = 5 expected = [0, 3, 1, 3, 0] result = voting.labels_count(annotations, nclasses, missing_value=mv) assert result == expected
def test_labels_count_non_default_missing_values(self): mv = -999 annotations = [ [1, 2, mv, mv], [mv, mv, 3, 3], [mv, 1, 3, 1], [mv, mv, mv, mv], ] nclasses = 5 expected = [0, 3, 1, 3, 0] result = voting.labels_count(annotations, nclasses, missing_value=mv) self.assertEqual(result, expected)
def test_labels_count_Error_Empty(self): with self.assertRaises(PVE): result = voting.labels_count([], 3)
def test_labels_count_Error_MV(self): with self.assertRaises(PVE): annotations = np.array([[MV,MV,MV]]) result = voting.labels_count(annotations, 3)
def test_missing_observations(self): annotations = np.array([[MV, MV, MV], [MV, MV, MV]]) with self.assertRaises(voting.PyannoValueError): voting.labels_count(annotations, 4, MV)
def test_label_count_exception_allmissing(self): with self.assertRaises(voting.PyannoValueError): annotations = np.zeros((2, 3)) + MV nclasses = 4 voting.labels_count(annotations, nclasses)
def test_label_count_exception_allmissing(self): with self.assertRaises(voting.PyannoValueError): annotations = np.zeros((2,3)) + MV nclasses = 4 voting.labels_count(annotations, nclasses)
def test_error2(self): annot2 = [] with self.assertRaises(PyannoValueError): voting.labels_count(annot2, 3)
def test_raise_error_empty(self): with self.assertRaises(voting.PyannoValueError): voting.labels_count([], 2)
def test_labels_count_Error_MV(self): with self.assertRaises(PVE): annotations = np.array([[MV, MV, MV]]) result = voting.labels_count(annotations, 3)
def test_valueError(self): with self.assertRaises(PyannoValueError): voting.labels_count([], 4) with self.assertRaises(PyannoValueError): voting.labels_count([MV, MV, MV, MV], 4)
def test_label_count_exception_emptyan(self): with self.assertRaises(voting.PyannoValueError): annotations = [] nclasses = 4 voting.labels_count(annotations, nclasses)
def test_raise_error_empty(self): mv = -10 with self.assertRaises(voting.PyannoValueError): voting.labels_count([mv, mv], 2, missing_value=mv)
def test_error1(self): annot1 = [[MV, MV], [MV, MV]] with self.assertRaises(PyannoValueError): voting.labels_count(annot1, 3)
def test_optional_missing_value_labels_count(self): mv = -99 result = voting.labels_count([[1, 1, 2], [mv, 1, 2]], 4, mv) expected = np.asarray([0., 3, 2, 0.]) assert_array_almost_equal(result, expected)
def test_optional_missing_value_labels_count(self): mv = -99 result = voting.labels_count([[1, 1, 2], [mv, 1, 2]], 4, mv) expected = np.asarray([ 0. , 3, 2, 0. ]) assert_array_almost_equal(result, expected)