added rdm save test
@@ -395,5 +395,32 @@ class TestCompareRDM(unittest.TestCase):
result = compare(self.test_rdm1, self.test_rdm2, method='cosine')
result = compare(self.test_rdm1, self.test_rdm2, method='kendall')
+
+class testSave(unittest.TestCase):
+ def test_save_load(self):
+ dis = np.zeros((8,10))
+ mes = "Euclidean"
+ des = {'subj':0}
+ pattern_des = {'type':np.array([0,1,2,2,4])}
+ rdm_des = {'session':np.array([0,1,2,2,4,5,6,7])}
+ rdms = rsa.rdm.RDMs(dissimilarities=dis,
+ pattern_descriptors=pattern_des,
+ dissimilarity_measure=mes,
+ descriptors=des,
+ rdm_descriptors=rdm_des)
+ try:
+ rdms.save('test')
+ rdms_loaded = rsa.rdm.load_rdm('test')
+ finally:
+ import os
+ os.remove('test.npy')
+ os.remove('test_desc.pkl')
+ assert rdms_loaded.n_cond == rdms.n_cond
+ assert np.all(rdms_loaded.pattern_descriptors['type'] == pattern_des['type'])
+ assert np.all(rdms_loaded.rdm_descriptors['session'] == rdm_des['session'])
+ assert rdms_loaded.descriptors['subj'] == 0
+
+
+
if __name__ == '__main__':
unittest.main()
