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


Python Epoch.merge方法代码示例

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


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

示例1: test_Epoch_merge

# 需要导入模块: from neo.core.epoch import Epoch [as 别名]
# 或者: from neo.core.epoch.Epoch import merge [as 别名]
    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)
开发者ID:INM-6,项目名称:python-neo,代码行数:46,代码来源:test_epoch.py

示例2: test_Epoch_merge

# 需要导入模块: from neo.core.epoch import Epoch [as 别名]
# 或者: from neo.core.epoch.Epoch import merge [as 别名]
    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)
开发者ID:Silmathoron,项目名称:python-neo,代码行数:43,代码来源:test_epoch.py


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