def test_R_inf(self): self.G.add_edge(3,0) self.G.add_edge(3,0) self.G.add_edge(3,1) AF_exp = np.array([ [7/15,0], [7/30,0], [0,0]]) np.testing.assert_array_almost_equal(cp.mat_AF(self.G,self.alpha),AF_exp,7,'error in AF calculation') RF = np.array([[1],[-1]]) I = np.identity(3) # mat_A ad vec_h are used in previosus tests so if they do not fail they can be used in this test A = cp.mat_A(self.G,self.alpha) h = cp.vec_h(self.G,self.alpha) R_inf_exp = (linalg.inv(I-A)).dot(h+(AF_exp.dot(RF))) np.testing.assert_array_almost_equal(cp.R_inf(self.G,self.alpha),R_inf_exp,7,'Error in R_inf function')
def test_R_inf(self): self.G.add_edge(3, 0) self.G.add_edge(3, 0) self.G.add_edge(3, 1) AF_exp = np.array([[7 / 15, 0], [7 / 30, 0], [0, 0]]) np.testing.assert_array_almost_equal(cp.mat_AF(self.G, self.alpha), AF_exp, 7, 'error in AF calculation') RF = np.array([[1], [-1]]) I = np.identity(3) # mat_A ad vec_h are used in previosus tests so if they do not fail they can be used in this test A = cp.mat_A(self.G, self.alpha) h = cp.vec_h(self.G, self.alpha) R_inf_exp = (linalg.inv(I - A)).dot(h + (AF_exp.dot(RF))) np.testing.assert_array_almost_equal(cp.R_inf(self.G, self.alpha), R_inf_exp, 7, 'Error in R_inf function')
def test_mat_A(self): A = np.array([[0, 0.7, 0], [0.35, 0, 0.35], [0, 0.7, 0]]) np.testing.assert_array_equal(cp.mat_A(self.G, self.alpha), A, 'error in matrix A calculation')
def test_mat_A(self): A = np.array([ [0,0.7,0], [0.35,0,0.35], [0,0.7,0]]) np.testing.assert_array_equal(cp.mat_A(self.G,self.alpha),A,'error in matrix A calculation')