def test_Potato_init(): """Test Potato""" covset = generate_cov(20, 3) labels = np.array([0, 1]).repeat(10) # init pt = Potato() # fit no labels pt.fit(covset) # fit with labels assert_raises(ValueError, pt.fit, covset, y=[1]) assert_raises(ValueError, pt.fit, covset, y=[0] * 20) assert_raises(ValueError, pt.fit, covset, y=[0, 2, 3] + [1] * 17) pt.fit(covset, labels) # transform pt.transform(covset) # transform pt.predict(covset) # lower threshold pt = Potato(threshold=1) pt.fit(covset)
def test_Potato_init(): """Test Potato""" covset = generate_cov(20, 3) labels = np.array([0, 1]).repeat(10) # init pt = Potato() # fit no labels pt.fit(covset) # fit with labels with pytest.raises(ValueError): pt.fit(covset, y=[1]) with pytest.raises(ValueError): pt.fit(covset, y=[0] * 20) with pytest.raises(ValueError): pt.fit(covset, y=[0, 2, 3] + [1] * 17) pt.fit(covset, labels) # transform pt.transform(covset) pt.transform(covset[0][np.newaxis, ...]) # transform a single trial # predict pt.predict(covset) pt.predict(covset[0][np.newaxis, ...]) # predict a single trial # predict_proba pt.predict_proba(covset) pt.predict_proba(covset[0][np.newaxis, ...]) # lower threshold pt = Potato(threshold=1) pt.fit(covset) # test positive labels pt = Potato(threshold=1, pos_label=2, neg_label=7) pt.fit(covset) assert_array_equal(np.unique(pt.predict(covset)), [2, 7]) # test with custom positive label pt.fit(covset, y=[2] * 20) # different positive and neg label with pytest.raises(ValueError): Potato(pos_label=0)
def test_Potato_init(): """Test Potato""" covset = generate_cov(20, 3) labels = np.array([0, 1]).repeat(10) # init pt = Potato() # fit no labels pt.fit(covset) # fit with labels assert_raises(ValueError, pt.fit, covset, y=[1]) assert_raises(ValueError, pt.fit, covset, y=[0] * 20) assert_raises(ValueError, pt.fit, covset, y=[0, 2, 3] + [1] * 17) pt.fit(covset, labels) # transform pt.transform(covset) # predict pt.predict(covset) # lower threshold pt = Potato(threshold=1) pt.fit(covset) # test positive labels pt = Potato(threshold=1, pos_label=2, neg_label=7) pt.fit(covset) assert_array_equal(np.unique(pt.predict(covset)), [2, 7]) # test with custom positive label pt.fit(covset, y=[2]*20) # different positive and neg label assert_raises(ValueError, Potato, pos_label=0)
def test_Potato_init(): """Test Potato""" covset = generate_cov(20, 3) labels = np.array([0, 1]).repeat(10) # init pt = Potato() # fit no labels pt.fit(covset) # fit with labels assert_raises(ValueError, pt.fit, covset, y=[1]) assert_raises(ValueError, pt.fit, covset, y=[0] * 20) assert_raises(ValueError, pt.fit, covset, y=[0, 2, 3] + [1] * 17) pt.fit(covset, labels) # transform pt.transform(covset) # predict pt.predict(covset) # lower threshold pt = Potato(threshold=1) pt.fit(covset) # test positive labels pt = Potato(threshold=1, pos_label=2, neg_label=7) pt.fit(covset) assert_array_equal(np.unique(pt.predict(covset)), [2, 7]) # test with custom positive label pt.fit(covset, y=[2] * 20) # different positive and neg label assert_raises(ValueError, Potato, pos_label=0)