Fixed getting empty selections.
This commit is contained in:
parent
56c07c6392
commit
91c1d8ea8b
|
@ -183,7 +183,9 @@ class Dataset:
|
||||||
backitems.sort()
|
backitems.sort()
|
||||||
sorted_ids=[ backitems[i][1] for i in range(0,len(backitems))]
|
sorted_ids=[ backitems[i][1] for i in range(0,len(backitems))]
|
||||||
|
|
||||||
if indices != None:
|
# we use id as scipy-arrays return a new array on boolean
|
||||||
|
# operations
|
||||||
|
if id(indices) != id(None):
|
||||||
return [sorted_ids[index] for index in indices]
|
return [sorted_ids[index] for index in indices]
|
||||||
else:
|
else:
|
||||||
return sorted_ids
|
return sorted_ids
|
||||||
|
|
|
@ -2,7 +2,7 @@ import unittest
|
||||||
import sys
|
import sys
|
||||||
sys.path.append('../..')
|
sys.path.append('../..')
|
||||||
from system.dataset import *
|
from system.dataset import *
|
||||||
from scipy import rand,shape
|
from scipy import rand,shape, array
|
||||||
|
|
||||||
class DatasetTest(unittest.TestCase):
|
class DatasetTest(unittest.TestCase):
|
||||||
|
|
||||||
|
@ -37,9 +37,12 @@ class DatasetTest(unittest.TestCase):
|
||||||
self.assertEquals(['gene_a', 'gene_b', 'gene_c'], data.get_identifiers('genes', [0, 1, 2]))
|
self.assertEquals(['gene_a', 'gene_b', 'gene_c'], data.get_identifiers('genes', [0, 1, 2]))
|
||||||
# "advanced" lookup
|
# "advanced" lookup
|
||||||
self.assertEquals(['gene_c', 'gene_a'], data.get_identifiers('genes', [2, 0]))
|
self.assertEquals(['gene_c', 'gene_a'], data.get_identifiers('genes', [2, 0]))
|
||||||
|
# handle empty matrix of indices
|
||||||
|
self.assertEquals([], data.get_identifiers('samples', array([])))
|
||||||
# other dimension
|
# other dimension
|
||||||
self.assertEquals(['sample_a', 'sample_b'], data.get_identifiers('samples', [0, 1]))
|
self.assertEquals(['sample_a', 'sample_b'], data.get_identifiers('samples', [0, 1]))
|
||||||
|
|
||||||
|
|
||||||
#def testExtraction(self):
|
#def testExtraction(self):
|
||||||
# ids = ['gene_a','gene_b']
|
# ids = ['gene_a','gene_b']
|
||||||
# dim_name = 'genes'
|
# dim_name = 'genes'
|
||||||
|
|
Reference in New Issue