Mercurial > pylearn
changeset 35:2508c373cf29
bug fix for reading byte matrices
author | bergstrj@iro.umontreal.ca |
---|---|
date | Fri, 18 Apr 2008 01:36:56 -0400 |
parents | 1b152f46ad0c |
children | 438440ba0627 810a8e3c85e1 |
files | __init__.py filetensor.py |
diffstat | 2 files changed, 17 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/__init__.py Thu Apr 17 12:49:48 2008 -0400 +++ b/__init__.py Fri Apr 18 01:36:56 2008 -0400 @@ -0,0 +1,2 @@ +import filetensor +import nnet_ops
--- a/filetensor.py Thu Apr 17 12:49:48 2008 -0400 +++ b/filetensor.py Fri Apr 18 01:36:56 2008 -0400 @@ -31,7 +31,7 @@ 0x1E3D4C52 : ('packed matrix', 0), #what is a packed matrix? 0x1E3D4C53 : ('float64', 8), 0x1E3D4C54 : ('int32', 4), - 0x1E3D4C55 : ('int8', 1), + 0x1E3D4C55 : ('uint8', 1), 0x1E3D4C56 : ('int16', 2), } _dtype_magic = { @@ -39,7 +39,7 @@ 'packed matrix': 0x1E3D4C52, 'float64': 0x1E3D4C53, 'int32': 0x1E3D4C54, - 'int8': 0x1E3D4C55, + 'uint8': 0x1E3D4C55, 'int16': 0x1E3D4C56 } @@ -150,19 +150,20 @@ if __name__ == '__main__': #a small test script, starts by reading sys.argv[1] - rval = read(sys.argv[1], slice(400), debug=True) #load from filename + rval = read(sys.argv[1], None, debug=True) #load from filename print 'rval', rval.shape, rval.size - f = file('/tmp/some_mat', 'w'); - write(f, rval) - print '' - f.close() - f = file('/tmp/some_mat', 'r'); - rval2 = read(f) #load from file handle - print 'rval2', rval2.shape, rval2.size + if 0: + f = file('/tmp/some_mat', 'w'); + write(f, rval) + print '' + f.close() + f = file('/tmp/some_mat', 'r'); + rval2 = read(f) #load from file handle + print 'rval2', rval2.shape, rval2.size - assert rval.dtype == rval2.dtype - assert rval.shape == rval2.shape - assert numpy.all(rval == rval2) - print 'ok' + assert rval.dtype == rval2.dtype + assert rval.shape == rval2.shape + assert numpy.all(rval == rval2) + print 'ok'