comparison _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
comparison
equal deleted inserted replaced
419:43d9aa93934e 420:040cb796f4e0
28 self.failUnless(gen.shape == mat.shape) 28 self.failUnless(gen.shape == mat.shape)
29 self.failUnless(numpy.all(gen == mat)) 29 self.failUnless(numpy.all(gen == mat))
30 30
31 def test_filename(self): 31 def test_filename(self):
32 gen = numpy.random.rand(1) 32 gen = numpy.random.rand(1)
33 write(self.fname, gen) 33 f = file(self.fname, 'w')
34 mat = read(self.fname, None, debug=False) #load from filename 34 write(f, gen)
35 f.close()
36 f = file(self.fname, 'r')
37 mat = read(f, None, debug=False) #load from filename
38 f.close()
35 self.failUnless(gen.shape == mat.shape) 39 self.failUnless(gen.shape == mat.shape)
36 self.failUnless(numpy.all(gen == mat)) 40 self.failUnless(numpy.all(gen == mat))
37 41
38 def testNd(self): 42 def testNd(self):
39 """shape and values are stored correctly for tensors of rank 0 to 5""" 43 """shape and values are stored correctly for tensors of rank 0 to 5"""