Exemplo n.º 1
0
 def test_memmap_read(self) :
     algebra.save('temp.npy', self.Mat)
     marray = algebra.open_memmap('temp.npy', mode="r")
     self.assertTrue(isinstance(marray, sp.ndarray))
     self.assertTrue(isinstance(marray, algebra.info_memmap))
     self.assertTrue(sp.allclose(marray, self.Mat))
     self.assertEqual(marray.info['a'], self.Mat.info['a'])
Exemplo n.º 2
0
 def test_memmap_read(self):
     algebra.save('temp.npy', self.Mat)
     marray = algebra.open_memmap('temp.npy', mode="r")
     self.assertTrue(isinstance(marray, sp.ndarray))
     self.assertTrue(isinstance(marray, algebra.info_memmap))
     self.assertTrue(sp.allclose(marray, self.Mat))
     self.assertEqual(marray.info['a'], self.Mat.info['a'])
Exemplo n.º 3
0
 def test_memmap_write(self) :
     marray = algebra.open_memmap('temp.npy', mode="w+",
                                  shape=self.Mat.shape,
                                  dtype=self.Mat.dtype,
                                  )
     marray[:] = self.Mat[:]
     marray.info = self.Mat.info
     del marray
     marray = None
     Loaded = algebra.load('temp.npy')
     self.assertTrue(isinstance(Loaded, sp.ndarray))
     self.assertTrue(isinstance(Loaded, algebra.info_array))
     self.assertTrue(sp.allclose(Loaded, self.Mat))
     self.assertEqual(Loaded.info['a'], self.Mat.info['a'])
Exemplo n.º 4
0
 def test_memmap_write(self):
     marray = algebra.open_memmap(
         'temp.npy',
         mode="w+",
         shape=self.Mat.shape,
         dtype=self.Mat.dtype,
     )
     marray[:] = self.Mat[:]
     marray.info = self.Mat.info
     del marray
     marray = None
     Loaded = algebra.load('temp.npy')
     self.assertTrue(isinstance(Loaded, sp.ndarray))
     self.assertTrue(isinstance(Loaded, algebra.info_array))
     self.assertTrue(sp.allclose(Loaded, self.Mat))
     self.assertEqual(Loaded.info['a'], self.Mat.info['a'])
Exemplo n.º 5
0
 def test_memmap_write_view(self) :
     marray = algebra.open_memmap('temp.npy', mode="w+",
                                  shape=self.Mat.shape,
                                  dtype=self.Mat.dtype,
                                  )
     # Work with a higher level view, make sure se can deal with it.
     # This is testing a bug I had earlier where base data's were
     # overwriting the meta data of higher level objects.
     inf = marray.info
     marray = marray.view(algebra.info_memmap)
     inf2 = marray.info
     marray[:] = self.Mat[:]
     marray.info.update(self.Mat.info)
     del marray
     marray = None
     Loaded = algebra.load('temp.npy')
     self.assertTrue(isinstance(Loaded, sp.ndarray))
     self.assertTrue(isinstance(Loaded, algebra.info_array))
     self.assertTrue(sp.allclose(Loaded, self.Mat))
     self.assertEqual(Loaded.info['a'], self.Mat.info['a'])
Exemplo n.º 6
0
 def test_memmap_write_view(self):
     marray = algebra.open_memmap(
         'temp.npy',
         mode="w+",
         shape=self.Mat.shape,
         dtype=self.Mat.dtype,
     )
     # Work with a higher level view, make sure se can deal with it.
     # This is testing a bug I had earlier where base data's were
     # overwriting the meta data of higher level objects.
     inf = marray.info
     marray = marray.view(algebra.info_memmap)
     inf2 = marray.info
     marray[:] = self.Mat[:]
     marray.info.update(self.Mat.info)
     del marray
     marray = None
     Loaded = algebra.load('temp.npy')
     self.assertTrue(isinstance(Loaded, sp.ndarray))
     self.assertTrue(isinstance(Loaded, algebra.info_array))
     self.assertTrue(sp.allclose(Loaded, self.Mat))
     self.assertEqual(Loaded.info['a'], self.Mat.info['a'])