Exemplo n.º 1
0
 def test_load_set_2(self):
     dd = DeepmdData(self.data_name)\
          .add('value_2', 1, atomic=True, must=True, type_sel = [1])
     data = dd._load_set(os.path.join(self.data_name, 'set.foo'))
     self.assertEqual(data['value_2'].shape, (self.nframes, 4))
     for ii in range(self.nframes):
         for jj in range(4):
             self.assertAlmostEqual(data['value_2'][ii][jj],
                                    self.value_2[ii][jj])
Exemplo n.º 2
0
 def test_reduce(self):
     dd = DeepmdData(self.data_name)\
          .add('test_atomic', 7, atomic=True, must=True)
     dd.reduce('redu', 'test_atomic')
     data = dd._load_set(os.path.join(self.data_name, 'set.foo'))
     self.assertEqual(data['find_test_atomic'], 1)
     self._comp_np_mat2(data['test_atomic'], self.test_atomic)
     self.assertEqual(data['find_redu'], 1)
     self._comp_np_mat2(data['redu'], self.redu_atomic)
Exemplo n.º 3
0
 def test_reduce_null(self):
     dd = DeepmdData(self.data_name)\
          .add('test_atomic_1', 7, atomic=True, must=False)
     dd.reduce('redu', 'test_atomic_1')
     data = dd._load_set(os.path.join(self.data_name, 'set.foo'))
     self.assertEqual(data['find_test_atomic_1'], 0)
     self._comp_np_mat2(data['test_atomic_1'],
                        np.zeros([self.nframes, self.natoms * 7]))
     self.assertEqual(data['find_redu'], 0)
     self._comp_np_mat2(data['redu'], np.zeros([self.nframes, 7]))
Exemplo n.º 4
0
 def test_shuffle(self):
     dd = DeepmdData(self.data_name)\
          .add('test_atomic', 7, atomic=True, must=True)\
          .add('test_frame', 5, atomic=False, must=True)
     data = dd._load_set(os.path.join(self.data_name, 'set.foo'))
     data_bk = copy.deepcopy(data)
     data, idx = dd._shuffle_data(data)
     self._comp_np_mat2(data_bk['coord'][idx, :], data['coord'])
     self._comp_np_mat2(data_bk['test_atomic'][idx, :], data['test_atomic'])
     self._comp_np_mat2(data_bk['test_frame'][idx, :], data['test_frame'])
Exemplo n.º 5
0
 def test_load_set(self):
     dd = DeepmdData(self.data_name)\
          .add('test_atomic', 7, atomic=True, must=True)\
          .add('test_frame', 5, atomic=False, must=True)\
          .add('test_null', 2, atomic=True, must=False)
     data = dd._load_set(os.path.join(self.data_name, 'set.foo'))
     nframes = data['coord'].shape[0]
     self.assertEqual(dd.get_numb_set(), 2)
     self.assertEqual(dd.get_type_map(), ['foo', 'bar'])
     self.assertEqual(dd.get_natoms(), 2)
     self.assertEqual(list(dd.get_natoms_vec(3)), [2, 2, 1, 1, 0])
     for ii in range(nframes):
         self.assertEqual(data['type'][ii][0], 0)
         self.assertEqual(data['type'][ii][1], 1)
     self.assertEqual(data['find_coord'], 1)
     self._comp_np_mat2(data['coord'], self.coord)
     self.assertEqual(data['find_test_atomic'], 1)
     self._comp_np_mat2(data['test_atomic'], self.test_atomic)
     self.assertEqual(data['find_test_frame'], 1)
     self._comp_np_mat2(data['test_frame'], self.test_frame)
     self.assertEqual(data['find_test_null'], 0)
     self._comp_np_mat2(data['test_null'], self.test_null)
Exemplo n.º 6
0
 def test_load_null_must(self):
     dd = DeepmdData(self.data_name)\
          .add('test_atomic_1', 7, atomic=True, must=True)
     with self.assertRaises(RuntimeError):
         data = dd._load_set(os.path.join(self.data_name, 'set.foo'))