Mercurial > pylearn
comparison pylearn/io/filetensor.py @ 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 | e06c0ff46d2a |
children | a6e634b83d88 |
comparison
equal
deleted
inserted
replaced
1411:68fdb895f53f | 1412:e1b5092b4a53 |
---|---|
200 f_start = f.tell() | 200 f_start = f.tell() |
201 | 201 |
202 rval = None | 202 rval = None |
203 if isinstance(f, gzip.GzipFile): | 203 if isinstance(f, gzip.GzipFile): |
204 assert subtensor is None, "Not implemented the subtensor case for gzip file" | 204 assert subtensor is None, "Not implemented the subtensor case for gzip file" |
205 d = f.read() | 205 d = f.read(_prod(dim)*elsize) |
206 rval = numpy.fromstring(d, dtype=magic_t, | 206 rval = numpy.fromstring(d, dtype=magic_t).reshape(dim) |
207 count=_prod(dim)).reshape(dim) | |
208 del d | 207 del d |
209 elif subtensor is None: | 208 elif subtensor is None: |
210 rval = numpy.fromfile(f, dtype=magic_t, count=_prod(dim)).reshape(dim) | 209 rval = numpy.fromfile(f, dtype=magic_t, count=_prod(dim)).reshape(dim) |
211 elif isinstance(subtensor, slice): | 210 elif isinstance(subtensor, slice): |
212 if subtensor.step not in (None, 1): | 211 if subtensor.step not in (None, 1): |