changeset 1412:e1b5092b4a53

allow to read gzip filetensor when there is more then 1 tensor in the file.
author Frederic Bastien <nouiz@nouiz.org>
date Wed, 02 Feb 2011 14:33:01 -0500
parents 68fdb895f53f
children 58dff11840f0
files pylearn/io/filetensor.py
diffstat 1 files changed, 2 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/io/filetensor.py	Wed Feb 02 12:39:35 2011 -0500
+++ b/pylearn/io/filetensor.py	Wed Feb 02 14:33:01 2011 -0500
@@ -202,9 +202,8 @@
     rval = None
     if isinstance(f, gzip.GzipFile):
         assert subtensor is None, "Not implemented the subtensor case for gzip file"
-        d = f.read()
-        rval = numpy.fromstring(d, dtype=magic_t, 
-                                count=_prod(dim)).reshape(dim)
+        d = f.read(_prod(dim)*elsize)
+        rval = numpy.fromstring(d, dtype=magic_t).reshape(dim)
         del d
     elif subtensor is None:
         rval = numpy.fromfile(f, dtype=magic_t, count=_prod(dim)).reshape(dim)