[med-svn] [python-mne] 274/376: FIX : None bug in copy_tree

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


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

yoh pushed a commit to annotated tag v0.1
in repository python-mne.

commit f28ba25247e06a9921ecbb2b2c0ffc0c03ff03fc
Author: Alexandre Gramfort <alexandre.gramfort at inria.fr>
Date:   Fri May 27 16:04:37 2011 -0400

    FIX : None bug in copy_tree
---
 mne/fiff/tree.py       | 31 ++++++++++++++++---------------
 mne/source_estimate.py |  4 ++--
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/mne/fiff/tree.py b/mne/fiff/tree.py
index bccd879..84d4919 100644
--- a/mne/fiff/tree.py
+++ b/mne/fiff/tree.py
@@ -131,21 +131,22 @@ def copy_tree(fidin, in_id, nodes, fidout):
             write_id(fidout, FIFF.FIFF_BLOCK_ID)
             write_id(fidout, FIFF.FIFF_PARENT_BLOCK_ID, node['id'])
 
-        for d in node.directory:
-            #   Do not copy these tags
-            if d.kind == FIFF.FIFF_BLOCK_ID or \
-                    d.kind == FIFF.FIFF_PARENT_BLOCK_ID or \
-                    d.kind == FIFF.FIFF_PARENT_FILE_ID:
-                continue
-
-            #   Read and write tags, pass data through transparently
-            fidin.seek(d.pos, 0)
-
-            s = fidin.read(4 * 4)
-            tag = Tag(*struct.unpack(">iIii", s))
-            tag.data = np.fromfile(fidin, dtype='>B', count=tag.size)
-
-            _write(fidout, tag.data, tag.kind, 1, tag.type, '>B')
+        if node.directory is not None:
+            for d in node.directory:
+                #   Do not copy these tags
+                if d.kind == FIFF.FIFF_BLOCK_ID or \
+                        d.kind == FIFF.FIFF_PARENT_BLOCK_ID or \
+                        d.kind == FIFF.FIFF_PARENT_FILE_ID:
+                    continue
+
+                #   Read and write tags, pass data through transparently
+                fidin.seek(d.pos, 0)
+
+                s = fidin.read(4 * 4)
+                tag = Tag(*struct.unpack(">iIii", s))
+                tag.data = np.fromfile(fidin, dtype='>B', count=tag.size)
+
+                _write(fidout, tag.data, tag.kind, 1, tag.type, '>B')
 
         for child in node['children']:
             copy_tree(fidin, in_id, child, fidout)
diff --git a/mne/source_estimate.py b/mne/source_estimate.py
index 66303b7..ef52ccd 100644
--- a/mne/source_estimate.py
+++ b/mne/source_estimate.py
@@ -44,13 +44,13 @@ def read_stc(filename):
     stc['tstep'] /= 1000.0
 
     # read number of vertices/sources
-    vertices_n = np.fromfile(fid, dtype=">I4", count=1)
+    vertices_n = int(np.fromfile(fid, dtype=">I4", count=1))
 
     # read the source vector
     stc['vertices'] = np.fromfile(fid, dtype=">I4", count=vertices_n)
 
     # read the number of timepts
-    data_n = np.fromfile(fid, dtype=">I4", count=1)
+    data_n = int(np.fromfile(fid, dtype=">I4", count=1))
 
     if ((file_length / 4 - 4 - vertices_n) % (data_n * vertices_n)) != 0:
         raise ValueError('incorrect stc file size')

-- 
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