added test including pyrsa dataset
@@ -7,8 +7,10 @@ Test for Dataset utils
"""
import unittest
-from pyrsa.util import data_utils as du
import numpy as np
+from pyrsa.util import data_utils as du
+import pyrsa.data as rsd
+
class TestGetUniqueUnsorted(unittest.TestCase):
def setUp(self):
@@ -17,6 +19,16 @@ class TestGetUniqueUnsorted(unittest.TestCase):
self.full_ints = np.array([99, 4, 66, 4, 33, 99])
self.unique_ints = np.array([99, 4, 66, 33])
+ measurements = np.zeros((4, 5))
+ des = {'session': 0, 'subj': 0}
+ obs_des = {'conds': np.array(['cond_foo', 'cond_bar', 'cond_foo', 'cond_bar'])}
+ chn_des = {'rois': np.array(['V1', 'V1', 'IT', 'IT', 'V4'])}
+ self.data = rsd.Dataset(measurements=measurements,
+ descriptors=des,
+ obs_descriptors=obs_des,
+ channel_descriptors=chn_des
+ )
+
def test_get_unique_unsorted_str(self):
self.array = np.array([self.full_str.split(' ')])
self.unique_unsorted = du.get_unique_unsorted(self.array)
@@ -27,5 +39,9 @@ class TestGetUniqueUnsorted(unittest.TestCase):
self.unique_unsorted = du.get_unique_unsorted(self.array)
assert np.all(self.unique_unsorted == self.unique_ints)
+ def test_get_unique_unsorted_ds(self):
+ unique_values = du.get_unique_unsorted(self.data.obs_descriptors['conds'])
+ assert np.all(np.array(['cond_foo', 'cond_bar']) == unique_values)
+
if __name__ == '__main__':
unittest.main()
