def test_onehot_to_sparse_singlelabel_int_raise_error(): """It raises error when passed multilabel data without multilabel flag.""" data = np.array([[0, 0, 0], [0, 0, 1], [1, 0, 1]]) try: CM._onehot_to_sparse(data) raise AssertionError except ValueError: pass else: raise AssertionError
def test_onehot_to_sparse_singlelabel_bool_raise_error(): """It raises error when passed multilabel data without multilabel flag.""" data = np.array([[False, False, False], [False, False, True], [True, False, True]]) try: CM._onehot_to_sparse(data) raise AssertionError except ValueError: pass else: raise AssertionError
def test_onehot_to_sparse_multilabel_bool(): """It returns expected sparse labels.""" data = np.array([[False, False, False], [False, False, True], [True, False, True]]) assert CM._onehot_to_sparse(data, multilabel=True) == [[], [2], [0, 2]]
def test_onehot_to_sparse_multilabel_int(): """It returns expected sparse labels.""" data = np.array([[0, 0, 0], [0, 0, 1], [1, 0, 1]]) assert CM._onehot_to_sparse(data, multilabel=True) == [[], [2], [0, 2]]
def test_onehot_to_sparse_singlelabel_bool(): """It returns expected sparse labels when passed bool onehot encoded labels.""" data = np.array([[False, False, True], [False, True, False], [True, False, False]]) assert CM._onehot_to_sparse(data) == [2, 1, 0]
def test_onehot_to_sparse_singlelabel_int(): """It returns expected sparse labels when passed integer onehot encoded labels.""" data = np.array([[0, 0, 1], [0, 1, 0], [1, 0, 0]]) assert CM._onehot_to_sparse(data) == [2, 1, 0]