def test_potato_1channel(get_covmats): n_trials, n_channels = 6, 1 covmats_1chan = get_covmats(n_trials, n_channels) pt = Potato() pt.fit_transform(covmats_1chan) pt.predict(covmats_1chan) pt.predict_proba(covmats_1chan)
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)