コード例 #1
0
 def test_path(self):
     tmpname = mktemp('', 'mmap', dir=self.tempdir)
     fp = memmap(Path(tmpname), dtype=self.dtype, mode='w+',
                 shape=self.shape)
     # os.path.realpath does not resolve symlinks on Windows
     # see: https://bugs.python.org/issue9949
     # use Path.resolve, just as memmap class does internally
     abspath = str(Path(tmpname).resolve())
     fp[:] = self.data[:]
     assert_equal(abspath, str(fp.filename.resolve()))
     b = fp[:1]
     assert_equal(abspath, str(b.filename.resolve()))
     del b
     del fp
コード例 #2
0
ファイル: test_records.py プロジェクト: OldJohn86/Numpy_CPP
 def test_tofile_fromfile(self):
     with temppath(suffix='.bin') as path:
         path = Path(path)
         np.random.seed(123)
         a = np.random.rand(10).astype('f8,i4,a5')
         a[5] = (0.5, 10, 'abcde')
         with path.open("wb") as fd:
             a.tofile(fd)
         x = np.core.records.fromfile(path, formats='f8,i4,a5', shape=10)
         assert_array_equal(x, a)
コード例 #3
0
 def test_path(self):
     tmpname = mktemp('', 'mmap', dir=self.tempdir)
     fp = memmap(Path(tmpname), dtype=self.dtype, mode='w+',
                 shape=self.shape)
     abspath = os.path.realpath(os.path.abspath(tmpname))
     fp[:] = self.data[:]
     self.assertEqual(abspath, str(fp.filename.resolve()))
     b = fp[:1]
     self.assertEqual(abspath, str(b.filename.resolve()))
     del b
     del fp
コード例 #4
0
 def test_tofile_fromfile(self):
     with temppath(suffix='.bin') as path:
         path = Path(path)
         a = np.empty(10, dtype='f8,i4,a5')
         a[5] = (0.5,10,'abcde')
         a.newbyteorder('<')
         with path.open("wb") as fd:
             a.tofile(fd)
         x = np.core.records.fromfile(path,
                                      formats='f8,i4,a5',
                                      shape=10,
                                      byteorder='<')
         assert_array_equal(x, a)