示例#1
0
def test_ERPcovariances():
    """Test fit ERPCovariances"""
    x = np.random.randn(10, 3, 100)
    labels = np.array([0, 1]).repeat(5)
    cov = ERPCovariances()
    cov.fit_transform(x, labels)
    cov = ERPCovariances(classes=[0])
    cov.fit_transform(x, labels)
    # assert raise svd
    assert_raises(TypeError, ERPCovariances, svd='42')
    cov = ERPCovariances(svd=1)
    assert_equal(cov.get_params(), dict(classes=None, estimator='scm', svd=1))
示例#2
0
def test_ERPcovariances():
    """Test fit ERPCovariances"""
    x = np.random.randn(10, 3, 100)
    labels = np.array([0, 1]).repeat(5)
    cov = ERPCovariances()
    cov.fit_transform(x, labels)
    cov = ERPCovariances(classes=[0])
    cov.fit_transform(x, labels)
    # assert raise svd
    assert_raises(TypeError, ERPCovariances, svd='42')
    cov = ERPCovariances(svd=1)
    assert_equal(cov.get_params(), dict(classes=None, estimator='scm',
                                        svd=1))
示例#3
0
def test_erp_covariances(estimator, svd, rndstate, get_labels):
    """Test fit ERPCovariances"""
    n_classes, n_matrices, n_channels, n_times = 2, 4, 3, 100
    x = rndstate.randn(n_matrices, n_channels, n_times)
    labels = get_labels(n_matrices, n_classes)
    cov = ERPCovariances(estimator=estimator, svd=svd)
    covmats = cov.fit_transform(x, labels)
    if svd is None:
        covsize = (n_classes + 1) * n_channels
    else:
        covsize = n_classes * svd + n_channels
    assert cov.get_params() == dict(classes=None, estimator=estimator, svd=svd)
    assert covmats.shape == (n_matrices, covsize, covsize)
    assert is_spsd(covmats)