# HG changeset patch # User Arnaud Bergeron # Date 1264709877 18000 # Node ID 032911ac4941d822117061672ba545eedf55ad04 # Parent 912be602c3ac0909435bcae8d22b841ca876052f Add option to use subtensor start in pylearn.io.filetensor diff -r 912be602c3ac -r 032911ac4941 pylearn/io/filetensor.py --- 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)