Ejemplo n.º 1
0
def test_merge_selections(signal):
    signals = []
    for i in range(10):
        jk = signal.jackknife_by_time(10, i, invert=True)
        signals.append(jk)

    merged = merge_selections(signals)

    # merged and signal should be identical
    assert np.sum(np.isnan(merged.as_continuous())) == 0
    assert np.array_equal(signal.as_continuous(), merged.as_continuous())
    assert signal.epochs.equals(merged.epochs)

    # This should not throw an exception
    merge_selections([signal, signal, signal])

    normalized = signal.normalized_by_mean()

    # This SHOULD throw an exception because they totally overlap
    with pytest.raises(ValueError):
        merge_selections([signal, normalized])

    jk2 = normalized.jackknife_by_time(10, 2, invert=True)
    jk3 = signal.jackknife_by_time(10, 3, invert=True)
    jk4 = signal.jackknife_by_time(10, 4, invert=True)

    # This will NOT throw an exception because they don't overlap
    merged = merge_selections([jk2, jk3])
    merged = merge_selections([jk2, jk4])

    # This SHOULD throw an exception
    with pytest.raises(ValueError):
        merged = merge_selections([signal, jk2])
Ejemplo n.º 2
0
def test_jackknife_by_time(signal):
    jsig = signal.jackknife_by_time(20, 2)
    isig = signal.jackknife_by_time(20, 2, invert=True)

    jdata = jsig.as_continuous()
    idata = isig.as_continuous()
    assert jdata.shape == (3, 200)
    assert idata.shape == (3, 200)

    assert np.sum(np.isnan(jdata)) == 30
    assert np.sum(np.isnan(idata)) == 570