Ejemplo n.º 1
0
 def test_rw_mat_scalar(self):
     np_mat = np.array([1])
     utterance.numpy_to_mat(np_mat, self.float_mat)
     self.assertEqual(self.float_mat.num_row, 1)
     self.assertEqual(self.float_mat.num_col, 1)
     np_mat_recover = utterance.mat_to_numpy(self.float_mat)
     self.assertEqual(np_mat_recover.shape, np_mat.shape)
     self.assertTrue((np_mat == np_mat_recover).all())
Ejemplo n.º 2
0
 def test_rw_mat_col_vec(self):
     np_mat = np.array([[1], [2], [3], [4]])
     num_row, num_col = np_mat.shape
     utterance.numpy_to_mat(np_mat, self.float_mat)
     self.assertEqual(self.float_mat.num_row, num_row)
     self.assertEqual(self.float_mat.num_col, num_col)
     np_mat_recover = utterance.mat_to_numpy(self.float_mat)
     self.assertEqual(np_mat_recover.shape, (num_row, num_col))
     self.assertTrue((np_mat == np_mat_recover).all())
Ejemplo n.º 3
0
 def test_rw_mat_row_vec(self):
     np_mat = np.array([1, 2, 3, 4])
     num_ele = len(np_mat)
     utterance.numpy_to_mat(np_mat, self.float_mat)
     self.assertEqual(self.float_mat.num_row, 1)
     self.assertEqual(self.float_mat.num_col, num_ele)
     np_mat_recover = utterance.mat_to_numpy(self.float_mat)
     self.assertEqual(np_mat_recover.shape, np_mat.shape)
     self.assertTrue((np_mat == np_mat_recover).all())
Ejemplo n.º 4
0
 def test_rw_mat_binary_mat(self):
     np_mat = np.array([[1, 0], [0, 1], [0, 0], [1, 1]])
     np_mat.astype(bool)
     num_row, num_col = np_mat.shape
     utterance.numpy_to_mat(np_mat, self.bool_mat)
     self.assertEqual(self.bool_mat.num_row, num_row)
     self.assertEqual(self.bool_mat.num_col, num_col)
     np_mat_recover = utterance.mat_to_numpy(self.bool_mat)
     self.assertEqual(np_mat_recover.shape, (num_row, num_col))
     self.assertTrue((np_mat == np_mat_recover).all())
Ejemplo n.º 5
0
 def test_rw_mat_int_mat(self):
     np_mat = np.array([[1, 1], [2, 2], [3, 3], [4, 4]])
     np_mat.astype(int)
     num_row, num_col = np_mat.shape
     utterance.numpy_to_mat(np_mat, self.int_mat)
     self.assertEqual(self.int_mat.num_row, num_row)
     self.assertEqual(self.int_mat.num_col, num_col)
     np_mat_recover = utterance.mat_to_numpy(self.int_mat)
     self.assertEqual(np_mat_recover.shape, (num_row, num_col))
     self.assertTrue((np_mat == np_mat_recover).all())