Exemplo n.º 1
0
 def test_memmap_read(self):
     file_io.save('temp.npy', self.Mat)
     marray = file_io.open_memmap('temp.npy', mode="r")
     self.assertTrue(isinstance(marray, sp.ndarray))
     self.assertTrue(isinstance(marray, info_header.InfoMemmap))
     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):
     file_io.save('temp.npy', self.Mat)
     marray = file_io.open_memmap('temp.npy', mode="r")
     self.assertTrue(isinstance(marray, sp.ndarray))
     self.assertTrue(isinstance(marray, info_header.InfoMemmap))
     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 = file_io.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 = file_io.load('temp.npy')
        self.assertTrue(isinstance(Loaded, sp.ndarray))
        self.assertTrue(isinstance(Loaded, info_header.InfoArray))
        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 = file_io.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 = file_io.load('temp.npy')
        self.assertTrue(isinstance(Loaded, sp.ndarray))
        self.assertTrue(isinstance(Loaded, info_header.InfoArray))
        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 = file_io.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(info_header.InfoMemmap)
        inf2 = marray.info
        marray[:] = self.Mat[:]
        marray.info.update(self.Mat.info)
        del marray
        marray = None
        Loaded = file_io.load('temp.npy')
        self.assertTrue(isinstance(Loaded, sp.ndarray))
        self.assertTrue(isinstance(Loaded, info_header.InfoArray))
        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 = file_io.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(info_header.InfoMemmap)
        inf2 = marray.info
        marray[:] = self.Mat[:]
        marray.info.update(self.Mat.info)
        del marray
        marray = None
        Loaded = file_io.load('temp.npy')
        self.assertTrue(isinstance(Loaded, sp.ndarray))
        self.assertTrue(isinstance(Loaded, info_header.InfoArray))
        self.assertTrue(sp.allclose(Loaded, self.Mat))
        self.assertEqual(Loaded.info['a'], self.Mat.info['a'])