Esempio n. 1
0
    def setUp(self):
        fd, path = tempfile.mkstemp()
        os.close(fd)
        self.temp_file_path = path
        with h5py.File(path, 'w') as f:
            f.require_group('x')

        self.hdf5file = h5py.File(path, 'r')
        self.deserializer = hdf5.HDF5Deserializer(self.hdf5file, strict=False)
Esempio n. 2
0
    def setUp(self):
        fd, path = tempfile.mkstemp()
        os.close(fd)
        self.temp_file_path = path

        child = link.Chain(linear=links.Linear(2, 3))
        parent = link.Chain(linear=links.Linear(3, 2), child=child)
        hdf5.save_hdf5(self.temp_file_path, parent)
        self.source = parent

        self.hdf5file = h5py.File(path, 'r')
        self.deserializer = hdf5.HDF5Deserializer(self.hdf5file, strict=False)
Esempio n. 3
0
 def test_string(self):
     fd, path = tempfile.mkstemp()
     os.close(fd)
     try:
         data = 'abc'
         with h5py.File(path, 'w') as f:
             f.create_dataset('str', data=data)
         with h5py.File(path, 'r') as f:
             deserializer = hdf5.HDF5Deserializer(f)
             ret = deserializer('str', '')
             self.assertEqual(ret, data)
     finally:
         os.remove(path)
Esempio n. 4
0
    def setUp(self):
        self.data = numpy.random.uniform(-1, 1, (2, 3)).astype(numpy.float32)

        fd, path = tempfile.mkstemp()
        os.close(fd)
        self.temp_file_path = path
        with h5py.File(path, 'w') as f:
            f.require_group('x')
            f.create_dataset('y', data=self.data)
            f.create_dataset('z', data=numpy.asarray(10))

        self.hdf5file = h5py.File(path, 'r')
        self.deserializer = hdf5.HDF5Deserializer(self.hdf5file)
Esempio n. 5
0
    def setUp(self):
        self.data = numpy.random.uniform(-1, 1, (2, 3)).astype(numpy.float32)

        fd, path = tempfile.mkstemp()
        os.close(fd)
        self.temp_file_path = path
        with h5py.File(path, 'w') as f:
            f.require_group('x')
            f.create_dataset('y', data=self.data)
            f.create_dataset('z', data=numpy.asarray(10))
            # h5py.Empty is introduced from 2.7.0
            if h5py.version.version_tuple >= (2, 7, 0):
                f.create_dataset('w', data=h5py.Empty('f'))

        self.hdf5file = h5py.File(path, 'r')
        self.deserializer = hdf5.HDF5Deserializer(self.hdf5file)
Esempio n. 6
0
 def _load(self, h5, obj, name):
     group = h5[name]
     serializer = hdf5.HDF5Deserializer(group)
     serializer.load(obj)