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])
def test_normalized_by_mean(signal): normalized_signal = signal.normalized_by_mean() data = normalized_signal.as_continuous() assert np.all(np.mean(data, axis=-1) == 0.0) assert np.allclose(np.std(data, axis=-1), 1.0)