Package mvpa :: Package tests :: Module test_splitsensana
[hide private]
[frames] | no frames]

Source Code for Module mvpa.tests.test_splitsensana

 1  #emacs: -*- mode: python-mode; py-indent-offset: 4; indent-tabs-mode: nil -*- 
 2  #ex: set sts=4 ts=4 sw=4 et: 
 3  ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 
 4  # 
 5  #   See COPYING file distributed along with the PyMVPA package for the 
 6  #   copyright and license terms. 
 7  # 
 8  ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 
 9  """Unit tests for PyMVPA SplittingSensitivityAnalyzer""" 
10   
11  from mvpa.datasets.splitters import NFoldSplitter 
12  from mvpa.measures.splitmeasure import SplitFeaturewiseMeasure 
13   
14  from tests_warehouse import * 
15  from tests_warehouse_clfs import * 
16   
17   
18 -class SplitSensitivityAnalyserTests(unittest.TestCase):
19 20 # XXX meta should work TODO 21 @sweepargs(svm=clfswh['linear', 'svm', '!meta'])
22 - def testAnalyzer(self, svm):
23 dataset = datasets['uni2small'] 24 25 svm_weigths = svm.getSensitivityAnalyzer() 26 27 sana = SplitFeaturewiseMeasure( 28 svm_weigths, 29 NFoldSplitter(cvtype=1), 30 enable_states=['maps']) 31 32 maps = sana(dataset) 33 nchunks = len(dataset.uniquechunks) 34 nfeatures = dataset.nfeatures 35 self.failUnless(len(maps) == nfeatures, 36 msg='Lengths of the map %d is different from number of features %d' 37 % (len(maps), nfeatures)) 38 self.failUnless(sana.states.isKnown('maps')) 39 allmaps = N.array(sana.maps) 40 self.failUnless(allmaps[:,0].mean() == maps[0]) 41 self.failUnless(allmaps.shape == (nchunks, nfeatures))
42 43
44 -def suite():
45 return unittest.makeSuite(SplitSensitivityAnalyserTests)
46 47 48 if __name__ == '__main__': 49 import runner 50