diff _test_filetensor.py @ 420:040cb796f4e0

Removed feature of passing the file as a pathname from filetensor.{read, write} Rationale: 1. The common pattern of multiple successive reads to load a list of arrays doesn't work for the string argument. 2. It isn't clear without checking the docs whether the write() will open a file in append mode, which could lead to bugs. 3. It's a fairly useless feature anyway, because the truly lazy programmer can call write(open(filename, 'w'), mat) to reproduce the old behaviour if he wants it, and without the open-mode ambiguity.
author James Bergstra <bergstrj@iro.umontreal.ca>
date Tue, 15 Jul 2008 12:57:21 -0400
parents b55c829695f1
children
line wrap: on
line diff
--- a/_test_filetensor.py	Mon Jul 14 16:48:02 2008 -0400
+++ b/_test_filetensor.py	Tue Jul 15 12:57:21 2008 -0400
@@ -30,8 +30,12 @@
 
     def test_filename(self):
         gen = numpy.random.rand(1)
-        write(self.fname, gen)
-        mat = read(self.fname, None, debug=False) #load from filename
+        f = file(self.fname, 'w')
+        write(f, gen)
+        f.close()
+        f = file(self.fname, 'r')
+        mat = read(f, None, debug=False) #load from filename
+        f.close()
         self.failUnless(gen.shape == mat.shape)
         self.failUnless(numpy.all(gen == mat))