• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python event.Event类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中neo.core.event.Event的典型用法代码示例。如果您正苦于以下问题:Python Event类的具体用法?Python Event怎么用?Python Event使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Event类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:msenoville,项目名称:python-neo,代码行数:29,代码来源:test_event.py


示例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)
开发者ID:bal47,项目名称:python-neo,代码行数:31,代码来源:test_event.py


示例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)
开发者ID:INM-6,项目名称:python-neo,代码行数:12,代码来源:test_event.py


示例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)
开发者ID:INM-6,项目名称:python-neo,代码行数:13,代码来源:test_event.py


示例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)
开发者ID:msenoville,项目名称:python-neo,代码行数:13,代码来源:test_event.py


示例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)
开发者ID:bal47,项目名称:python-neo,代码行数:13,代码来源:test_event.py


示例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'])
开发者ID:msenoville,项目名称:python-neo,代码行数:17,代码来源:test_event.py


示例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'])
开发者ID:msenoville,项目名称:python-neo,代码行数:28,代码来源:test_event.py


示例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)
开发者ID:INM-6,项目名称:python-neo,代码行数:29,代码来源:test_event.py


示例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'])
开发者ID:NeuroArchive,项目名称:python-neo,代码行数:18,代码来源:test_event.py


示例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)
开发者ID:INM-6,项目名称:python-neo,代码行数:44,代码来源:test_event.py


示例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)
开发者ID:INM-6,项目名称:python-neo,代码行数:19,代码来源:test_event.py


示例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'])
开发者ID:msenoville,项目名称:python-neo,代码行数:19,代码来源:test_event.py


示例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)
开发者ID:INM-6,项目名称:python-neo,代码行数:22,代码来源:test_event.py


示例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)
开发者ID:msenoville,项目名称:python-neo,代码行数:38,代码来源:test_event.py


示例16: test_Event_creation

    def test_Event_creation(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)

        assert_arrays_equal(evt.times, [1.1, 1.5, 1.7]*pq.ms)
        assert_arrays_equal(evt.labels, np.array(['test event 1',
                                                  'test event 2',
                                                  'test event 3'], dtype='S'))
        self.assertEqual(evt.name, 'test')
        self.assertEqual(evt.description, 'tester')
        self.assertEqual(evt.file_origin, 'test.file')
        self.assertEqual(evt.annotations['test0'], [1, 2])
        self.assertEqual(evt.annotations['test1'], 1.1)
        self.assertEqual(evt.annotations['test2'], 'y1')
        self.assertTrue(evt.annotations['test3'])
开发者ID:msenoville,项目名称:python-neo,代码行数:23,代码来源:test_event.py


示例17: test_Event_creation

    def test_Event_creation(self):
        params = {'test2': 'y1', 'test3': True}
        arr_ann = {'names': ['a', 'b', 'c'], 'index': np.arange(10, 13)}
        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,
                    array_annotations=arr_ann, **params)
        evt.annotate(test1=1.1, test0=[1, 2])
        assert_neo_object_is_compliant(evt)

        assert_arrays_equal(evt.times, [1.1, 1.5, 1.7] * pq.ms)
        assert_arrays_equal(evt.labels,
                            np.array(['test event 1', 'test event 2', 'test event 3'], dtype='S'))
        self.assertEqual(evt.name, 'test')
        self.assertEqual(evt.description, 'tester')
        self.assertEqual(evt.file_origin, 'test.file')
        self.assertEqual(evt.annotations['test0'], [1, 2])
        self.assertEqual(evt.annotations['test1'], 1.1)
        self.assertEqual(evt.annotations['test2'], 'y1')
        self.assertTrue(evt.annotations['test3'])
        assert_arrays_equal(evt.array_annotations['names'], np.array(['a', 'b', 'c']))
        assert_arrays_equal(evt.array_annotations['index'], np.arange(10, 13))
        self.assertIsInstance(evt.array_annotations, ArrayDict)
开发者ID:INM-6,项目名称:python-neo,代码行数:23,代码来源:test_event.py


示例18: test_Event_creation

    def test_Event_creation(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)

        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["test0"], [1, 2])
        self.assertEqual(evt.annotations["test1"], 1.1)
        self.assertEqual(evt.annotations["test2"], "y1")
        self.assertTrue(evt.annotations["test3"])
开发者ID:bal47,项目名称:python-neo,代码行数:23,代码来源:test_event.py


示例19: test__children

    def test__children(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)

        segment = Segment(name='seg1')
        segment.events = [evt]
        segment.create_many_to_one_relationship()

        self.assertEqual(evt._container_child_objects, ())
        self.assertEqual(evt._data_child_objects, ())
        self.assertEqual(evt._single_parent_objects, ('Segment',))
        self.assertEqual(evt._multi_child_objects, ())
        self.assertEqual(evt._multi_parent_objects, ())
        self.assertEqual(evt._child_properties, ())

        self.assertEqual(evt._single_child_objects, ())

        self.assertEqual(evt._container_child_containers, ())
        self.assertEqual(evt._data_child_containers, ())
        self.assertEqual(evt._single_child_containers, ())
        self.assertEqual(evt._single_parent_containers, ('segment',))
        self.assertEqual(evt._multi_child_containers, ())
        self.assertEqual(evt._multi_parent_containers, ())

        self.assertEqual(evt._child_objects, ())
        self.assertEqual(evt._child_containers, ())
        self.assertEqual(evt._parent_objects, ('Segment',))
        self.assertEqual(evt._parent_containers, ('segment',))

        self.assertEqual(evt.children, ())
        self.assertEqual(len(evt.parents), 1)
        self.assertEqual(evt.parents[0].name, 'seg1')

        evt.create_many_to_one_relationship()
        evt.create_many_to_many_relationship()
        evt.create_relationship()
        assert_neo_object_is_compliant(evt)
开发者ID:NeuroArchive,项目名称:python-neo,代码行数:42,代码来源:test_event.py


示例20: test_to_epoch

    def test_to_epoch(self):
        seg = Segment(name="test")
        event = Event(times=np.array([5.0, 12.0, 23.0, 45.0]), units="ms",
                      labels=np.array(["A", "B", "C", "D"]))
        event.segment = seg

        # Mode 1
        epoch = event.to_epoch()
        self.assertIsInstance(epoch, Epoch)
        assert_array_equal(epoch.times.magnitude, np.array([5.0, 12.0, 23.0]))
        assert_array_equal(epoch.durations.magnitude, np.array([7.0, 11.0, 22.0]))
        assert_array_equal(epoch.labels, np.array(['A-B', 'B-C', 'C-D']))

        # Mode 2
        epoch = event.to_epoch(pairwise=True)
        assert_array_equal(epoch.times.magnitude, np.array([5.0, 23.0]))
        assert_array_equal(epoch.durations.magnitude, np.array([7.0, 22.0]))
        assert_array_equal(epoch.labels, np.array(['A-B', 'C-D']))

        # Mode 3 (scalar)
        epoch = event.to_epoch(durations=2.0 * pq.ms)
        assert_array_equal(epoch.times.magnitude, np.array([5.0, 12.0, 23.0, 45.0]))
        assert_array_equal(epoch.durations.magnitude, np.array([2.0, 2.0, 2.0, 2.0]))
        self.assertEqual(epoch.durations.size, 4)
        assert_array_equal(epoch.labels, np.array(['A', 'B', 'C', 'D']))

        # Mode 3 (array)
        epoch = event.to_epoch(durations=np.array([2.0, 3.0, 4.0, 5.0]) * pq.ms)
        assert_array_equal(epoch.times.magnitude, np.array([5.0, 12.0, 23.0, 45.0]))
        assert_array_equal(epoch.durations.magnitude, np.array([2.0, 3.0, 4.0, 5.0]))
        assert_array_equal(epoch.labels, np.array(['A', 'B', 'C', 'D']))

        # Error conditions
        self.assertRaises(ValueError, event.to_epoch, pairwise=True, durations=2.0 * pq.ms)

        odd_event = Event(times=np.array([5.0, 12.0, 23.0]), units="ms",
                          labels=np.array(["A", "B", "C"]))
        self.assertRaises(ValueError, odd_event.to_epoch, pairwise=True)
开发者ID:INM-6,项目名称:python-neo,代码行数:38,代码来源:test_event.py



注:本文中的neo.core.event.Event类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python baseio.BaseIO类代码示例发布时间:2022-05-27
下一篇:
Python epoch.Epoch类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap