def test__children(self): params = {'test2': 'y1', 'test3': True} evta = EventArray([1.1, 1.5, 1.7] * pq.ms, labels=np.array( ['test event 1', 'test event 2', 'test event 3'], dtype='S'), name='test', description='tester', file_origin='test.file', test1=1, **params) evta.annotate(test1=1.1, test0=[1, 2]) assert_neo_object_is_compliant(evta) segment = Segment(name='seg1') segment.eventarrays = [evta] segment.create_many_to_one_relationship() self.assertEqual(evta._single_parent_objects, ('Segment', )) self.assertEqual(evta._multi_parent_objects, ()) self.assertEqual(evta._single_parent_containers, ('segment', )) self.assertEqual(evta._multi_parent_containers, ()) self.assertEqual(evta._parent_objects, ('Segment', )) self.assertEqual(evta._parent_containers, ('segment', )) self.assertEqual(len(evta.parents), 1) self.assertEqual(evta.parents[0].name, 'seg1') assert_neo_object_is_compliant(evta)
def test_EventArray_creation(self): params = {'testarg2': 'yes', 'testarg3': True} evta = EventArray([1.1, 1.5, 1.7] * pq.ms, labels=np.array( ['test event 1', 'test event 2', 'test event 3'], dtype='S'), name='test', description='tester', file_origin='test.file', testarg1=1, **params) evta.annotate(testarg1=1.1, testarg0=[1, 2, 3]) assert_neo_object_is_compliant(evta) assert_arrays_equal(evta.times, [1.1, 1.5, 1.7] * pq.ms) assert_arrays_equal( evta.labels, np.array(['test event 1', 'test event 2', 'test event 3'], dtype='S')) self.assertEqual(evta.name, 'test') self.assertEqual(evta.description, 'tester') self.assertEqual(evta.file_origin, 'test.file') self.assertEqual(evta.annotations['testarg0'], [1, 2, 3]) self.assertEqual(evta.annotations['testarg1'], 1.1) self.assertEqual(evta.annotations['testarg2'], 'yes') self.assertTrue(evta.annotations['testarg3'])
def test__children(self): params = {'test2': 'y1', 'test3': True} evta = EventArray([1.1, 1.5, 1.7]*pq.ms, labels=np.array(['test event 1', 'test event 2', 'test event 3'], dtype='S'), name='test', description='tester', file_origin='test.file', test1=1, **params) evta.annotate(test1=1.1, test0=[1, 2]) assert_neo_object_is_compliant(evta) segment = Segment(name='seg1') segment.eventarrays = [evta] segment.create_many_to_one_relationship() self.assertEqual(evta._single_parent_objects, ('Segment',)) self.assertEqual(evta._multi_parent_objects, ()) self.assertEqual(evta._single_parent_containers, ('segment',)) self.assertEqual(evta._multi_parent_containers, ()) self.assertEqual(evta._parent_objects, ('Segment',)) self.assertEqual(evta._parent_containers, ('segment',)) self.assertEqual(len(evta.parents), 1) self.assertEqual(evta.parents[0].name, 'seg1') assert_neo_object_is_compliant(evta)
def test__pretty(self): evta = EventArray([1.1, 1.5, 1.7]*pq.ms, labels=np.array(['test event 1', 'test event 2', 'test event 3'], dtype='S'), name='test', description='tester', file_origin='test.file') evta.annotate(test1=1.1, test0=[1, 2]) assert_neo_object_is_compliant(evta) prepr = pretty(evta) targ = ("EventArray\nname: '%s'\ndescription: '%s'\nannotations: %s" % (evta.name, evta.description, pretty(evta.annotations))) self.assertEqual(prepr, targ)
def test__pretty(self): evta = EventArray([1.1, 1.5, 1.7] * pq.ms, labels=np.array( ['test event 1', 'test event 2', 'test event 3'], dtype='S'), name='test', description='tester', file_origin='test.file') evta.annotate(test1=1.1, test0=[1, 2]) assert_neo_object_is_compliant(evta) prepr = pretty(evta) targ = ("EventArray\nname: '%s'\ndescription: '%s'\nannotations: %s" % (evta.name, evta.description, pretty(evta.annotations))) self.assertEqual(prepr, targ)
def test_EventArray_repr(self): params = {'testarg2': 'yes', 'testarg3': True} evta = EventArray([1.1, 1.5, 1.7]*pq.ms, labels=np.array(['test event 1', 'test event 2', 'test event 3'], dtype='S'), name='test', description='tester', file_origin='test.file', testarg1=1, **params) evta.annotate(testarg1=1.1, testarg0=[1, 2, 3]) assert_neo_object_is_compliant(evta) targ = ('<EventArray: test event [email protected] ms, test event [email protected] ms, ' + 'test event [email protected] ms>') res = repr(evta) self.assertEqual(targ, res)
def test_EventArray_repr(self): params = {'testarg2': 'yes', 'testarg3': True} evta = EventArray([1.1, 1.5, 1.7] * pq.ms, labels=np.array( ['test event 1', 'test event 2', 'test event 3'], dtype='S'), name='test', description='tester', file_origin='test.file', testarg1=1, **params) evta.annotate(testarg1=1.1, testarg0=[1, 2, 3]) assert_neo_object_is_compliant(evta) targ = ('<EventArray: test event [email protected] ms, test event [email protected] ms, ' + 'test event [email protected] ms>') res = repr(evta) self.assertEqual(targ, res)
def test_EventArray_creation(self): params = {'testarg2': 'yes', 'testarg3': True} evta = EventArray([1.1, 1.5, 1.7]*pq.ms, labels=np.array(['test event 1', 'test event 2', 'test event 3'], dtype='S'), name='test', description='tester', file_origin='test.file', testarg1=1, **params) evta.annotate(testarg1=1.1, testarg0=[1, 2, 3]) assert_neo_object_is_compliant(evta) assert_arrays_equal(evta.times, [1.1, 1.5, 1.7]*pq.ms) assert_arrays_equal(evta.labels, np.array(['test event 1', 'test event 2', 'test event 3'], dtype='S')) self.assertEqual(evta.name, 'test') self.assertEqual(evta.description, 'tester') self.assertEqual(evta.file_origin, 'test.file') self.assertEqual(evta.annotations['testarg0'], [1, 2, 3]) self.assertEqual(evta.annotations['testarg1'], 1.1) self.assertEqual(evta.annotations['testarg2'], 'yes') self.assertTrue(evta.annotations['testarg3'])