def test_comodulogram_dar_models(): # Smoke test with DAR models for klass in (AR, DAR, HAR, StableDAR): if klass is StableDAR: model = klass(ordar=10, ordriv=2, iter_newton=10) else: model = klass(ordar=10, ordriv=2) comod = fast_comod(method=model) assert_true(~np.any(np.isnan(comod)))
def test_progress_bar(): n = 10 app = ProgressBar(title='Testing progressBar', max_value=n - 1, spinner=True) assert_false(app.closed) for k in range(n): app.update_with_increment_value(1) time.sleep(0.001) assert_true(app.closed) n = 10 app = ProgressBar(title='Testing progressBar', max_value=n - 1, spinner=True) app.update(n) assert_true(app.closed)
def test_comod_correct_maximum(): # Test that the PAC is maximum at the correct location in the comodulogram for method in ALL_PAC_METRICS: est = ComodTest(method=method, progress_bar=True).fit(signal) comod = est.comod_ # test the shape of the comodulogram assert_array_equal(comod.shape, (n_low, n_high)) # the bicoherence metrics fail this test with current parameters if method in BICOHERENCE_PAC_METRICS or method == 'jiang': continue low_fq_0, high_fq_0, max_pac = est.get_maximum_pac() assert_equal(low_fq_0, low_fq) assert_equal(high_fq_0, high_fq) assert_equal(max_pac, comod.max()) assert_true(np.all(comod > 0))
def test_raw_to_mask_no_events(): # test that no events gives masks entirely False raw = create_empty_raw() low_sig, high_sig, mask = raw_to_mask(raw, ixs=0, events=None, tmin=None, tmax=None) for one_mask in mask: assert_true(np.all(~one_mask)) # test with no events and tmin, tmax tmin, tmax = 0.2, 0.6 low_sig, high_sig, mask = raw_to_mask(raw, ixs=0, events=None, tmin=tmin, tmax=tmax) for one_mask in mask: assert_equal(one_mask[~one_mask].size, int((tmax - tmin) * raw.info['sfreq']))
def test_is_power2(): for i in range(1, 10): assert_true(is_power2(2**i)) assert_false(is_power2(2**i + 1))