本文整理汇总了Python中mne.utils.run_tests_if_main函数的典型用法代码示例。如果您正苦于以下问题:Python run_tests_if_main函数的具体用法?Python run_tests_if_main怎么用?Python run_tests_if_main使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run_tests_if_main函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_run_tests_if_main
def test_run_tests_if_main():
"""Test run_tests_if_main functionality."""
x = []
def test_a():
x.append(True)
@np.testing.dec.skipif(True)
def test_b():
return
try:
__name__ = '__main__'
run_tests_if_main(measure_mem=False) # dual meas causes problems
def test_c():
raise RuntimeError
try:
__name__ = '__main__'
run_tests_if_main(measure_mem=False) # dual meas causes problems
except RuntimeError:
pass
else:
raise RuntimeError('Error not raised')
finally:
del __name__
assert_true(len(x) == 2)
assert_true(x[0] and x[1])
示例2: _get_epochs
"""
import matplotlib.pyplot as plt
epochs = _get_epochs()
assert_raises(ValueError, epochs.plot_drop_log)
epochs.drop_bad_epochs()
warnings.simplefilter('always', UserWarning)
with warnings.catch_warnings(record=True):
epochs.plot_drop_log()
plot_drop_log([['One'], [], []])
plot_drop_log([['One'], ['Two'], []])
plot_drop_log([['One'], ['One', 'Two'], []])
plt.close('all')
@requires_version('scipy', '0.12')
def test_plot_psd_epochs():
"""Test plotting epochs psd (+topomap)
"""
import matplotlib.pyplot as plt
epochs = _get_epochs()
epochs.plot_psd()
assert_raises(RuntimeError, epochs.plot_psd_topomap,
bands=[(0, 0.01, 'foo')]) # no freqs in range
epochs.plot_psd_topomap()
plt.close('all')
run_tests_if_main()
示例3: transform_surface_to
# Compare to original points
transform_surface_to(fwd['src'][0], 'head', fwd['mri_head_t'])
transform_surface_to(fwd['src'][1], 'head', fwd['mri_head_t'])
src_rr = np.concatenate([s['rr'][v] for s, v in zip(fwd['src'], vertices)],
axis=0)
src_nn = np.concatenate([s['nn'][v] for s, v in zip(fwd['src'], vertices)],
axis=0)
# MNE-C skips the last "time" point :(
dip.crop(dip_c.times[0], dip_c.times[-1])
src_rr, src_nn = src_rr[:-1], src_nn[:-1]
# check that we did at least as well
corrs, dists, gc_dists, amp_errs, gofs = [], [], [], [], []
for d in (dip_c, dip):
new = d.pos
diffs = new - src_rr
corrs += [np.corrcoef(src_rr.ravel(), new.ravel())[0, 1]]
dists += [np.sqrt(np.mean(np.sum(diffs * diffs, axis=1)))]
gc_dists += [180 / np.pi * np.mean(np.arccos(np.sum(src_nn * d.ori,
axis=1)))]
amp_errs += [np.sqrt(np.mean((amp - d.amplitude) ** 2))]
gofs += [np.mean(d.gof)]
assert_true(dists[0] >= dists[1], 'dists: %s' % dists)
assert_true(corrs[0] <= corrs[1], 'corrs: %s' % corrs)
assert_true(gc_dists[0] >= gc_dists[1], 'gc-dists (ori): %s' % gc_dists)
assert_true(amp_errs[0] >= amp_errs[1], 'amplitude errors: %s' % amp_errs)
# assert_true(gofs[0] <= gofs[1], 'gof: %s' % gofs)
run_tests_if_main(False)