Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0
This repository has been archived on 2024-07-04. You can view files and clone it, but cannot push or open issues or pull requests.
laydi/test/system/datasettest.py

34 lines
1.0 KiB
Python
Raw Normal View History

2006-04-17 00:57:50 +02:00
import unittest
import sys
sys.path.append('../../system')
from dataset import *
from scipy import rand,shape
class DatasetTest(unittest.TestCase):
def setUp(self):
self.dim_0_ids = ['sample_a','sample_b']
self.dim_1_ids = ['gene_a','gene_b','gene_c']
self.dim_labels = ['samples','genes']
self.def_list = [[self.dim_labels[0],self.dim_0_ids],[self.dim_labels[1],self.dim_1_ids]]
self.array = rand(2,3)
self.testdata = Dataset(self.array,self.def_list)
def testCreation(self):
assert self.testdata._data == self.array
assert 'sample_a' in self.testdata.ids['samples'].keys()
assert 'gene_b' in self.testdata.ids['genes'].keys()
def testExtraction(self):
ids = ['gene_a','gene_b']
dim_name = 'genes'
subset = self.testdata.extract_data(ids,dim_name)
assert shape(subset._data) == (2,2)
assert subset.ids[dim_name].keys() == ids
assert subset.ids[dim_name].values() == [0,1]
if __name__ == '__main__':
unittest.main()