changeset 894:032911ac4941

Add option to use subtensor start in pylearn.io.filetensor
author Arnaud Bergeron <abergeron@gmail.com>
date Thu, 28 Jan 2010 15:17:57 -0500
parents 912be602c3ac
children 257a39cce72c
files pylearn/io/filetensor.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/io/filetensor.py	Wed Jan 27 09:56:37 2010 -0500
+++ b/pylearn/io/filetensor.py	Thu Jan 28 15:17:57 2010 -0500
@@ -183,6 +183,7 @@
 
     """
     magic_t, elsize, ndim, dim, dim_size = _read_header(f,debug)
+    f_start = f.tell()
 
     rval = None
     if subtensor is None:
@@ -192,8 +193,8 @@
             raise NotImplementedError('slice with step', subtensor.step)
         if subtensor.start not in (None, 0):
             bytes_per_row = _prod(dim[1:]) * elsize
-            raise NotImplementedError('slice with start', subtensor.start)
-        dim[0] = min(dim[0], subtensor.stop)
+            f.seek(f_start+subtensor.start * bytes_per_row)
+        dim[0] = min(dim[0], subtensor.stop) - subtensor.start
         rval = numpy.fromfile(f, dtype=magic_t, count=_prod(dim)).reshape(dim)
     else:
         raise NotImplementedError('subtensor access not written yet:', subtensor)