def test_center_distance_matrix_inplace(self): dm_expected = f_matrix(e_matrix(self.small_mat)) # make copy of matrix to test inplace centering matrix_copy = copy.deepcopy(self.small_mat) dm_centered = center_distance_matrix(matrix_copy, inplace=False) # ensure that matrix_copy was NOT modified inplace self.assertTrue(np.array_equal(matrix_copy, self.small_mat)) # and ensure that the result of centering was correct npt.assert_almost_equal(dm_expected, dm_centered) # next, sort same matrix inplace matrix_copy2 = copy.deepcopy(self.small_mat) dm_centered_inp = center_distance_matrix(matrix_copy2, inplace=True) # and ensure that the result of inplace centering was correct npt.assert_almost_equal(dm_expected, dm_centered_inp)
def test_e_matrix(self): E = e_matrix(self.matrix) expected_E = np.array([[-0.5, -2., -4.5], [-8., -12.5, -18.]]) npt.assert_almost_equal(E, expected_E)
def test_e_matrix(self): E = e_matrix(self.matrix) expected_E = np.array([[-0.5, -2., -4.5], [-8., -12.5, -18.]]) npt.assert_almost_equal(E, expected_E)