当前位置: 首页>>代码示例>>Python>>正文


Python Event.merge方法代码示例

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


在下文中一共展示了Event.merge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_Event_merge

# 需要导入模块: from neo.core.event import Event [as 别名]
# 或者: from neo.core.event.Event import merge [as 别名]
    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,代码行数:46,代码来源:test_event.py

示例2: test_Event_merge

# 需要导入模块: from neo.core.event import Event [as 别名]
# 或者: from neo.core.event.Event import merge [as 别名]
    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,代码行数:40,代码来源:test_event.py


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