def test_compute_debiasing():
 rng = np.random.RandomState(42)
 G = rng.randn(10, 4)
 X = rng.randn(4, 20)
 debias_true = np.arange(1, 5, dtype=np.float)
 M = np.dot(G, (X * debias_true[:, np.newaxis]))
 debias = compute_bias(M, G, X, max_iter=10000, n_orient=1, tol=1e-07)
 assert_almost_equal(debias, debias_true, decimal=5)
 debias = compute_bias(M, G, X, max_iter=10000, n_orient=2, tol=1e-05)
 assert_almost_equal(debias, [1.8, 1.8, 3.72, 3.72], decimal=2)

def test_compute_debiasing ( ) : rng = np . random . RandomState ( 42 ) G = rng . randn ( 10 , 4 ) X = rng . randn ( 4 , 20 ) debias_true = np . arange ( 1 , 5 , dtype = np . float ) M = np . dot ( G , ( X * debias_true [ : , np . newaxis ] ) ) debias = compute_bias ( M , G , X , max_iter = 10000 , n_orient = 1 , tol = 1e-07 ) assert_almost_equal ( debias , debias_true , decimal = 5 ) debias = compute_bias ( M , G , X , max_iter = 10000 , n_orient = 2 , tol = 1e-05 ) assert_almost_equal ( debias , [ 1.8 , 1.8 , 3.72 , 3.72 ] , decimal = 2 )
test source amplitude debiasing .