[med-svn] [python-mne] 33/353: ENH: test for raw

Yaroslav Halchenko debian at onerussian.com
Fri Nov 27 17:24:27 UTC 2015


This is an automated email from the git hooks/post-receive script.

yoh pushed a commit to tag 0.4
in repository python-mne.

commit d2155cc5b0678fc60f1b1e69989a9f05149c1af8
Author: Martin Luessi <mluessi at nmr.mgh.harvard.edu>
Date:   Thu Dec 22 13:14:39 2011 -0500

    ENH: test for raw
---
 mne/tests/test_raw.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/mne/tests/test_raw.py b/mne/tests/test_raw.py
new file mode 100644
index 0000000..b43aaec
--- /dev/null
+++ b/mne/tests/test_raw.py
@@ -0,0 +1,46 @@
+import os.path as op
+
+import numpy as np
+from numpy.testing import assert_array_almost_equal
+
+from ..datasets import sample
+from ..fiff import pick_types
+
+from ..fiff.raw import Raw
+
+examples_folder = op.join(op.dirname(__file__), '..', '..', 'examples')
+data_path = sample.data_path(examples_folder)
+fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_raw.fif')
+
+
+def test_read_write():
+    raw_orig = Raw(fname)
+    data_orig, times_orig = raw_orig[:, :]
+
+    tmp_fname = 'tmp.fif'
+    raw_orig.save(tmp_fname)
+
+    raw = Raw(tmp_fname)
+    data, times = raw[:, :]
+
+    assert_array_almost_equal(data_orig, data)
+    assert_array_almost_equal(times_orig, times)
+
+
+def test_modify_data():
+    raw = Raw(fname)
+
+    n_samp = raw.last_samp - raw.first_samp
+    picks = pick_types(raw.info, meg='grad')
+
+    data = np.random.randn(len(picks), n_samp / 2)
+
+    raw[picks, :n_samp / 2] = data
+
+    tmp_fname = 'tmp.fif'
+    raw.save(tmp_fname)
+
+    raw_new = Raw(tmp_fname)
+    data_new, _ = raw_new[picks, :n_samp / 2]
+
+    assert_array_almost_equal(data, data_new)
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/python-mne.git



More information about the debian-med-commit mailing list