def test_max_opinion_diff(self): gm.local_update(self.G, self.alpha) diff_expected = 0.36 diff_actual = gm.max_opinion_difference(gm.get_opinion(self.G), gm.get_opinion(self.G_copy)) np.testing.assert_almost_equal( diff_actual, diff_expected, 7, 'error in max_opinion_difference function')
def test_local_update(self): # expected R after one local update iteration R_expected = [ 0.14, 0.28, 0.14] # Update nodes opnion gm.local_update(self.G,self.alpha) R_actual = [] for i in self.G: R_actual += [self.G.node[i]['opinion']] np.testing.assert_array_almost_equal(R_actual,R_expected,6,'error in local update function.', True)
def test_max_opinion_diff(self): gm.local_update(self.G,self.alpha) diff_expected = 0.36 diff_actual = gm.max_opinion_difference(gm.get_opinion(self.G),gm.get_opinion(self.G_copy)) np.testing.assert_almost_equal(diff_actual, diff_expected,7, 'error in max_opinion_difference function')