diff filetensor.py @ 35:2508c373cf29

bug fix for reading byte matrices
author bergstrj@iro.umontreal.ca
date Fri, 18 Apr 2008 01:36:56 -0400
parents bb92087cb0f6
children 2b6656b2ef52
line wrap: on
line diff
--- 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'