Package parsimony :: Package utils :: Module testing
[hide private]
[frames] | no frames]

Source Code for Module parsimony.utils.testing

 1  # -*- coding: utf-8 -*- 
 2  """ 
 3  Created on ??? ??? ?? ??:??:?? ???? 
 4   
 5  Copyright (c) 2013-2014, CEA/DSV/I2BM/Neurospin. All rights reserved. 
 6   
 7  @author:  Tommy Löfstedt 
 8  @email:   tommy.loefstedt@cea.fr 
 9  @license: BSD 3-clause. 
10  """ 
11  import numpy as np 
12  import utils 
13   
14  #from sklearn.utils.testing import assert_array_almost_equal 
15   
16  #from nose.tools import assert_equal 
17  #from nose.tools import assert_not_equal 
18  #from nose.tools import assert_true 
19  #from nose.tools import assert_false 
20  #from nose.tools import assert_raises 
21  #from nose.tools import raises 
22  #from nose import SkipTest 
23  #from nose import with_setup 
24   
25  #from numpy.testing import assert_almost_equal 
26  #from numpy.testing import assert_array_equal 
27  #from numpy.testing import assert_array_almost_equal 
28  #from numpy.testing import assert_array_less 
29   
30   
31  #'assert_array_almost_equal',  
32  __all__ = ["orth_matrix"] 
33  #           'check_ortho'] 
34             #"assert_equal", "assert_not_equal", "assert_raises", "raises", 
35  #           "with_setup", "assert_true", "assert_false", "assert_almost_equal", 
36  #           "assert_array_equal", 
37  #           "assert_array_less"] 
38   
39   
40 -def orth_matrix(n=10):
41 Y = utils.rand(n, 1) 42 X = utils.zeros(n, n) 43 if n > 2: 44 for j in xrange(n - 1): 45 x = utils.rand(n, 1) 46 while abs(abs(utils.corr(x, Y)) - j / (n - 1.0)) > 0.005: 47 x = utils.rand(n, 1) 48 if utils.corr(x, Y) < 0: 49 x *= -1 50 X[:, j] = x.ravel() 51 52 X[:, n - 1] = Y.ravel() 53 54 return X, Y
55 56 57 #def check_ortho(M, err_msg): 58 # K = np.dot(M.T, M) 59 # assert_array_almost_equal(K, np.diag(np.diag(K)), err_msg=err_msg) 60