def test_Epoch_merge(self): params1 = {'test2': 'y1', 'test3': True} params2 = {'test2': 'no', 'test4': False} paramstarg = {'test2': 'yes;no', 'test3': True, 'test4': False} epc1 = Epoch( [1.1, 1.5, 1.7] * pq.ms, durations=[20, 40, 60] * pq.us, labels=np.array( ['test epoch 1 1', 'test epoch 1 2', 'test epoch 1 3'], dtype='S'), name='test', description='tester 1', file_origin='test.file', test1=1, **params1) epc2 = Epoch( [2.1, 2.5, 2.7] * pq.us, durations=[3, 5, 7] * pq.ms, labels=np.array( ['test epoch 2 1', 'test epoch 2 2', 'test epoch 2 3'], dtype='S'), name='test', description='tester 2', file_origin='test.file', test1=1, **params2) epctarg = Epoch( [1.1, 1.5, 1.7, .0021, .0025, .0027] * pq.ms, durations=[20, 40, 60, 3000, 5000, 7000] * pq.ns, labels=np.array([ 'test epoch 1 1', 'test epoch 1 2', 'test epoch 1 3', 'test epoch 2 1', 'test epoch 2 2', 'test epoch 2 3' ], dtype='S'), name='test', description='merge(tester 1, tester 2)', file_origin='test.file', test1=1, **paramstarg) assert_neo_object_is_compliant(epc1) assert_neo_object_is_compliant(epc2) assert_neo_object_is_compliant(epctarg) epcres = epc1.merge(epc2) assert_neo_object_is_compliant(epcres) assert_same_sub_schema(epctarg, epcres)
def test_Epoch_merge(self): params1 = {'test2': 'y1', 'test3': True} params2 = {'test2': 'no', 'test4': False} paramstarg = {'test2': 'yes;no', 'test3': True, 'test4': False} arr_ann1 = {'index': np.arange(10, 13)} arr_ann2 = {'index': np.arange(3), 'test': ['a', 'b', 'c']} epc1 = Epoch([1.1, 1.5, 1.7] * pq.ms, durations=[20, 40, 60] * pq.us, labels=np.array(['test epoch 1 1', 'test epoch 1 2', 'test epoch 1 3'], dtype='S'), name='test', description='tester 1', file_origin='test.file', test1=1, array_annotations=arr_ann1, **params1) epc2 = Epoch([2.1, 2.5, 2.7] * pq.us, durations=[3, 5, 7] * pq.ms, labels=np.array(['test epoch 2 1', 'test epoch 2 2', 'test epoch 2 3'], dtype='S'), name='test', description='tester 2', file_origin='test.file', test1=1, array_annotations=arr_ann2, **params2) epctarg = Epoch([1.1, 1.5, 1.7, .0021, .0025, .0027] * pq.ms, durations=[20, 40, 60, 3000, 5000, 7000] * pq.us, labels=np.array(['test epoch 1 1', 'test epoch 1 2', 'test epoch 1 3', 'test epoch 2 1', 'test epoch 2 2', 'test epoch 2 3'], dtype='S'), name='test', description='merge(tester 1, tester 2)', file_origin='test.file', array_annotations={'index': [10, 11, 12, 0, 1, 2]}, test1=1, **paramstarg) assert_neo_object_is_compliant(epc1) assert_neo_object_is_compliant(epc2) assert_neo_object_is_compliant(epctarg) with warnings.catch_warnings(record=True) as w: epcres = epc1.merge(epc2) self.assertTrue(len(w), 1) self.assertEqual(w[0].category, UserWarning) self.assertSequenceEqual(str(w[0].message), "The following array annotations were " "omitted, because they were only present" " in one of the merged objects: " "[] from the one that was merged " "into and ['test'] from the one that " "was merged into the other") assert_neo_object_is_compliant(epcres) assert_same_sub_schema(epctarg, epcres) # Remove this, when array_annotations are added to assert_same_sub_schema assert_arrays_equal(epcres.array_annotations['index'], np.array([10, 11, 12, 0, 1, 2])) self.assertTrue('test' not in epcres.array_annotations) self.assertIsInstance(epcres.array_annotations, ArrayDict)
def test_Epoch_merge(self): params1 = {'test2': 'y1', 'test3': True} params2 = {'test2': 'no', 'test4': False} paramstarg = {'test2': 'yes;no', 'test3': True, 'test4': False} epc1 = Epoch([1.1, 1.5, 1.7]*pq.ms, durations=[20, 40, 60]*pq.us, labels=np.array(['test epoch 1 1', 'test epoch 1 2', 'test epoch 1 3'], dtype='S'), name='test', description='tester 1', file_origin='test.file', test1=1, **params1) epc2 = Epoch([2.1, 2.5, 2.7]*pq.us, durations=[3, 5, 7]*pq.ms, labels=np.array(['test epoch 2 1', 'test epoch 2 2', 'test epoch 2 3'], dtype='S'), name='test', description='tester 2', file_origin='test.file', test1=1, **params2) epctarg = Epoch([1.1, 1.5, 1.7, .0021, .0025, .0027]*pq.ms, durations=[20, 40, 60, 3000, 5000, 7000]*pq.ns, labels=np.array(['test epoch 1 1', 'test epoch 1 2', 'test epoch 1 3', 'test epoch 2 1', 'test epoch 2 2', 'test epoch 2 3'], dtype='S'), name='test', description='merge(tester 1, tester 2)', file_origin='test.file', test1=1, **paramstarg) assert_neo_object_is_compliant(epc1) assert_neo_object_is_compliant(epc2) assert_neo_object_is_compliant(epctarg) epcres = epc1.merge(epc2) assert_neo_object_is_compliant(epcres) assert_same_sub_schema(epctarg, epcres)