def testRandStochasticRightSeed(self): "Random: Stochastic - right with seed" seed = 12345 U0 = rand_stochastic(10, kind='right', seed=seed) U1 = rand_stochastic(10, kind='right', seed=None) U2 = rand_stochastic(10, kind='right', seed=seed) assert_(U0 != U1) assert_(U0 == U2)
def testRandStochasticLeftSeed(self): "Random: Stochastic - left with seed" seed = 12345 U0 = rand_stochastic(10, seed=seed) U1 = rand_stochastic(10, seed=None) U2 = rand_stochastic(10, seed=seed) assert_(U0 != U1) assert_(U0 == U2)
def testRandStochasticRight(self): 'Random: Stochastic - right' Q = [rand_stochastic(10, kind='right') for k in range(5)] for i in range(5): A = Q[i].data for j in range(10): assert_(np.abs(np.sum(A.getrow(j).todense().real)-1.0) < 1e-15)
def testRandStochasticLeft(self): 'Random: Stochastic - left' Q = [rand_stochastic(10) for k in range(5)] for i in range(5): A = Q[i].data.tocsc() for j in range(10): assert_(np.abs(np.sum(A.getcol(j).todense().real)-1.0) < 1e-15)
def test_rand_stochastic(kind): """ Random Qobjs: Test random stochastic """ random_qobj = rand_stochastic(5, kind=kind) axis = {"left":0, "right":1}[kind] np.testing.assert_allclose(np.sum(random_qobj.full(), axis=axis), 1, atol=1e-14)
def testRandStochasticRight(self): 'Random: Stochastic - right' Q = [rand_stochastic(10, kind='right') for k in range(5)] for i in range(5): A = Q[i].data for j in range(10): assert_( np.abs(np.sum(A.getrow(j).todense().real) - 1.0) < 1e-15)
def testRandStochasticLeft(self): 'Random: Stochastic - left' Q = [rand_stochastic(10) for k in range(5)] for i in range(5): A = Q[i].data.tocsc() for j in range(10): assert_( np.abs(np.sum(A.getcol(j).todense().real) - 1.0) < 1e-15)