本文整理汇总了Python中neo.core.event.Event类的典型用法代码示例。如果您正苦于以下问题:Python Event类的具体用法?Python Event怎么用?Python Event使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Event类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test__children
def test__children(self):
params = {'test2': 'y1', 'test3': True}
evt = Event([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)
evt.annotate(test1=1.1, test0=[1, 2])
assert_neo_object_is_compliant(evt)
segment = Segment(name='seg1')
segment.events = [evt]
segment.create_many_to_one_relationship()
self.assertEqual(evt._single_parent_objects, ('Segment',))
self.assertEqual(evt._multi_parent_objects, ())
self.assertEqual(evt._single_parent_containers, ('segment',))
self.assertEqual(evt._multi_parent_containers, ())
self.assertEqual(evt._parent_objects, ('Segment',))
self.assertEqual(evt._parent_containers, ('segment',))
self.assertEqual(len(evt.parents), 1)
self.assertEqual(evt.parents[0].name, 'seg1')
assert_neo_object_is_compliant(evt)
示例2: test__children
def test__children(self):
params = {"test2": "y1", "test3": True}
evt = Event(
1.5 * pq.ms,
label="test epoch",
name="test",
description="tester",
file_origin="test.file",
test1=1,
**params
)
evt.annotate(test1=1.1, test0=[1, 2])
assert_neo_object_is_compliant(evt)
segment = Segment(name="seg1")
segment.events = [evt]
segment.create_many_to_one_relationship()
self.assertEqual(evt._single_parent_objects, ("Segment",))
self.assertEqual(evt._multi_parent_objects, ())
self.assertEqual(evt._single_parent_containers, ("segment",))
self.assertEqual(evt._multi_parent_containers, ())
self.assertEqual(evt._parent_objects, ("Segment",))
self.assertEqual(evt._parent_containers, ("segment",))
self.assertEqual(len(evt.parents), 1)
self.assertEqual(evt.parents[0].name, "seg1")
assert_neo_object_is_compliant(evt)
示例3: test__pretty
def test__pretty(self):
evt = Event([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')
evt.annotate(test1=1.1, test0=[1, 2])
assert_neo_object_is_compliant(evt)
prepr = pretty(evt)
targ = ("Event\nname: '%s'\ndescription: '%s'\nannotations: %s"
"" % (evt.name, evt.description, pretty(evt.annotations)))
self.assertEqual(prepr, targ)
示例4: test_Event_repr
def test_Event_repr(self):
params = {'test2': 'y1', 'test3': True}
evt = Event([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)
evt.annotate(test1=1.1, test0=[1, 2])
assert_neo_object_is_compliant(evt)
targ = ('<Event: test event [email protected] ms, test event [email protected] ms, ' + 'test event [email protected] ms>')
res = repr(evt)
self.assertEqual(targ, res)
示例5: test__time_slice
def test__time_slice(self):
data = [2, 3, 4, 5] * pq.ms
evt = Event(data, foo='bar')
evt1 = evt.time_slice(2.2 * pq.ms, 4.2 * pq.ms)
assert_arrays_equal(evt1.times, [3, 4] * pq.ms)
self.assertEqual(evt.annotations, evt1.annotations)
evt2 = evt.time_slice(None, 4.2 * pq.ms)
assert_arrays_equal(evt2.times, [2, 3, 4] * pq.ms)
evt3 = evt.time_slice(2.2 * pq.ms, None)
assert_arrays_equal(evt3.times, [3, 4, 5] * pq.ms)
示例6: test__pretty
def test__pretty(self):
evt = Event(1.5 * pq.ms, label="test epoch", name="test", description="tester", file_origin="test.file")
evt.annotate(targ1=1.1, targ0=[1])
assert_neo_object_is_compliant(evt)
prepr = pretty(evt)
targ = "Event\nname: '%s'\ndescription: '%s'\nannotations: %s" % (
evt.name,
evt.description,
pretty(evt.annotations),
)
self.assertEqual(prepr, targ)
示例7: test_time_slice_empty
def test_time_slice_empty(self):
params = {'test2': 'y1', 'test3': True}
evt = Event([]*pq.ms,
name='test', description='tester',
file_origin='test.file',
test1=1, **params)
evt.annotate(test1=1.1, test0=[1, 2])
result = evt.time_slice(t_start=0.0001, t_stop=30.0 )
assert_neo_object_is_compliant(evt)
assert_arrays_equal(evt, result)
self.assertEqual(evt.name, result.name)
self.assertEqual(evt.description, result.description)
self.assertEqual(evt.file_origin, result.file_origin)
self.assertEqual(evt.annotations['test0'], result.annotations['test0'])
self.assertEqual(evt.annotations['test1'], result.annotations['test1'])
self.assertEqual(evt.annotations['test2'], result.annotations['test2'])
示例8: test_time_slice_differnt_units
def test_time_slice_differnt_units(self):
params = {'test2': 'y1', 'test3': True}
evt = Event([0.1, 0.5, 1.1, 1.5, 1.7, 2.2, 2.9, 3.1, 3.3]*pq.ms,
name='test', description='tester',
file_origin='test.file',
test1=1, **params)
assert_neo_object_is_compliant(evt)
evt.annotate(test1=1.1, test0=[1, 2])
targ = Event([ 2.2, 2.9 ]*pq.ms,
name='test', description='tester',
file_origin='test.file',
test1=1, **params)
assert_neo_object_is_compliant(targ)
targ.annotate(test1=1.1, test0=[1, 2])
t_start = 0.002 * pq.s
t_stop = 0.003 * pq.s
result = evt.time_slice(t_start, t_stop)
assert_arrays_equal(targ, result)
self.assertEqual(targ.name, result.name)
self.assertEqual(targ.description, result.description)
self.assertEqual(targ.file_origin, result.file_origin)
self.assertEqual(targ.annotations['test0'], result.annotations['test0'])
self.assertEqual(targ.annotations['test1'], result.annotations['test1'])
self.assertEqual(targ.annotations['test2'], result.annotations['test2'])
示例9: test_time_slice_differnt_units
def test_time_slice_differnt_units(self):
params = {'test2': 'y1', 'test3': True}
arr_ann = {'index': np.arange(9), 'test': np.arange(100, 109)}
evt = Event([0.1, 0.5, 1.1, 1.5, 1.7, 2.2, 2.9, 3.1, 3.3] * pq.ms, name='test',
description='tester', file_origin='test.file', test1=1,
array_annotations=arr_ann, **params)
assert_neo_object_is_compliant(evt)
evt.annotate(test1=1.1, test0=[1, 2])
targ = Event([2.2, 2.9] * pq.ms, name='test', description='tester',
file_origin='test.file', test1=1, **params)
assert_neo_object_is_compliant(targ)
targ.annotate(test1=1.1, test0=[1, 2])
t_start = 0.002 * pq.s
t_stop = 0.003 * pq.s
result = evt.time_slice(t_start, t_stop)
assert_arrays_equal(targ, result)
self.assertEqual(targ.name, result.name)
self.assertEqual(targ.description, result.description)
self.assertEqual(targ.file_origin, result.file_origin)
self.assertEqual(targ.annotations['test0'], result.annotations['test0'])
self.assertEqual(targ.annotations['test1'], result.annotations['test1'])
self.assertEqual(targ.annotations['test2'], result.annotations['test2'])
assert_arrays_equal(result.array_annotations['index'], np.arange(5, 7))
assert_arrays_equal(result.array_annotations['test'], np.arange(105, 107))
self.assertIsInstance(result.array_annotations, ArrayDict)
示例10: test_Event_creation
def test_Event_creation(self):
params = {'testarg2': 'yes', 'testarg3': True}
evt = Event(1.5*pq.ms,
label='test epoch', name='test', description='tester',
file_origin='test.file',
testarg1=1, **params)
evt.annotate(testarg1=1.1, testarg0=[1, 2, 3])
assert_neo_object_is_compliant(evt)
self.assertEqual(evt.time, 1.5*pq.ms)
self.assertEqual(evt.label, 'test epoch')
self.assertEqual(evt.name, 'test')
self.assertEqual(evt.description, 'tester')
self.assertEqual(evt.file_origin, 'test.file')
self.assertEqual(evt.annotations['testarg0'], [1, 2, 3])
self.assertEqual(evt.annotations['testarg1'], 1.1)
self.assertEqual(evt.annotations['testarg2'], 'yes')
self.assertTrue(evt.annotations['testarg3'])
示例11: test_Event_merge
def test_Event_merge(self):
warnings.simplefilter("always")
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']}
evt1 = Event([1.1, 1.5, 1.7] * pq.ms,
labels=np.array(['test event 1 1', 'test event 1 2', 'test event 1 3'],
dtype='S'), name='test', description='tester 1',
file_origin='test.file', array_annotations=arr_ann1, test1=1, **params1)
evt2 = Event([2.1, 2.5, 2.7] * pq.us,
labels=np.array(['test event 2 1', 'test event 2 2', 'test event 2 3'],
dtype='S'), name='test', description='tester 2',
file_origin='test.file', array_annotations=arr_ann2, test1=1, **params2)
evttarg = Event([1.1, 1.5, 1.7, .0021, .0025, .0027] * pq.ms,
labels=np.array(['test event 1 1', 'test event 1 2', 'test event 1 3',
'test event 2 1', 'test event 2 2', 'test event 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(evt1)
assert_neo_object_is_compliant(evt2)
assert_neo_object_is_compliant(evttarg)
with warnings.catch_warnings(record=True) as w:
evtres = evt1.merge(evt2)
self.assertEqual(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(evtres)
assert_same_sub_schema(evttarg, evtres)
# Remove this, when array_annotations are added to assert_same_sub_schema
assert_arrays_equal(evtres.array_annotations['index'], np.array([10, 11, 12, 0, 1, 2]))
self.assertTrue('test' not in evtres.array_annotations)
self.assertIsInstance(evtres.array_annotations, ArrayDict)
示例12: test_time_slice_empty
def test_time_slice_empty(self):
params = {'test2': 'y1', 'test3': True}
arr_ann = {'index': np.array([]), 'test': np.array([])}
evt = Event([] * pq.ms, name='test', description='tester', file_origin='test.file',
test1=1, array_annotations=arr_ann, **params)
evt.annotate(test1=1.1, test0=[1, 2])
result = evt.time_slice(t_start=0.0001, t_stop=30.0)
assert_neo_object_is_compliant(evt)
assert_arrays_equal(evt, result)
self.assertEqual(evt.name, result.name)
self.assertEqual(evt.description, result.description)
self.assertEqual(evt.file_origin, result.file_origin)
self.assertEqual(evt.annotations['test0'], result.annotations['test0'])
self.assertEqual(evt.annotations['test1'], result.annotations['test1'])
self.assertEqual(evt.annotations['test2'], result.annotations['test2'])
assert_arrays_equal(result.array_annotations['index'], np.asarray([]))
assert_arrays_equal(result.array_annotations['test'], np.asarray([]))
self.assertIsInstance(result.array_annotations, ArrayDict)
示例13: test_time_slice_out_of_boundries
def test_time_slice_out_of_boundries(self):
params = {'test2': 'y1', 'test3': True}
evt = Event([0.1, 0.5, 1.1, 1.5, 1.7, 2.2, 2.9, 3.0, 3.1, 3.3]*pq.ms,
name='test', description='tester',
file_origin='test.file',
test1=1, **params)
evt.annotate(test1=1.1, test0=[1, 2])
assert_neo_object_is_compliant(evt)
targ = evt
result = evt.time_slice(t_start=0.0001, t_stop=30.0 )
assert_arrays_equal(targ, result)
self.assertEqual(evt.name, result.name)
self.assertEqual(evt.description, result.description)
self.assertEqual(evt.file_origin, result.file_origin)
self.assertEqual(evt.annotations['test0'], result.annotations['test0'])
self.assertEqual(evt.annotations['test1'], result.annotations['test1'])
self.assertEqual(evt.annotations['test2'], result.annotations['test2'])
示例14: test_slice
def test_slice(self):
params = {'test2': 'y1', 'test3': True}
arr_ann = {'index': np.arange(10), 'test': np.arange(100, 110)}
evt = Event([0.1, 0.5, 1.1, 1.5, 1.7, 2.2, 2.9, 3.0, 3.1, 3.3] * pq.ms, name='test',
description='tester', file_origin='test.file', test1=1,
array_annotations=arr_ann, **params)
evt.annotate(test1=1.1, test0=[1, 2])
assert_neo_object_is_compliant(evt)
targ = Event([2.2, 2.9, 3.0] * pq.ms)
result = evt[5:8]
assert_arrays_equal(targ, result)
self.assertEqual(evt.name, result.name)
self.assertEqual(evt.description, result.description)
self.assertEqual(evt.file_origin, result.file_origin)
self.assertEqual(evt.annotations['test0'], result.annotations['test0'])
self.assertEqual(evt.annotations['test1'], result.annotations['test1'])
self.assertEqual(evt.annotations['test2'], result.annotations['test2'])
assert_arrays_equal(result.array_annotations['index'], np.arange(5, 8))
assert_arrays_equal(result.array_annotations['test'], np.arange(105, 108))
self.assertIsInstance(result.array_annotations, ArrayDict)
示例15: test_Event_merge
def test_Event_merge(self):
params1 = {'test2': 'y1', 'test3': True}
params2 = {'test2': 'no', 'test4': False}
paramstarg = {'test2': 'yes;no',
'test3': True,
'test4': False}
evt1 = Event([1.1, 1.5, 1.7]*pq.ms,
labels=np.array(['test event 1 1',
'test event 1 2',
'test event 1 3'], dtype='S'),
name='test', description='tester 1',
file_origin='test.file',
test1=1, **params1)
evt2 = Event([2.1, 2.5, 2.7]*pq.us,
labels=np.array(['test event 2 1',
'test event 2 2',
'test event 2 3'], dtype='S'),
name='test', description='tester 2',
file_origin='test.file',
test1=1, **params2)
evttarg = Event([1.1, 1.5, 1.7, .0021, .0025, .0027]*pq.ms,
labels=np.array(['test event 1 1',
'test event 1 2',
'test event 1 3',
'test event 2 1',
'test event 2 2',
'test event 2 3'], dtype='S'),
name='test',
description='merge(tester 1, tester 2)',
file_origin='test.file',
test1=1, **paramstarg)
assert_neo_object_is_compliant(evt1)
assert_neo_object_is_compliant(evt2)
assert_neo_object_is_compliant(evttarg)
evtres = evt1.merge(evt2)
assert_neo_object_is_compliant(evtres)
assert_same_sub_schema(evttarg, evtres)