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

Python epoch.Epoch类代码示例

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

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



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

示例1: test_as_array

 def test_as_array(self):
     times = [2, 3, 4, 5]
     durations = [0.1, 0.2, 0.3, 0.4]
     epc = Epoch(times * pq.ms, durations=durations * pq.ms)
     epc_as_arr = epc.as_array(units='ms')
     self.assertIsInstance(epc_as_arr, np.ndarray)
     assert_array_equal(times, epc_as_arr)
开发者ID:CINPLA,项目名称:python-neo,代码行数:7,代码来源:test_epoch.py


示例2: test__children

    def test__children(self):
        params = {'test2': 'y1', 'test3': True}
        epc = Epoch([1.1, 1.5, 1.7]*pq.ms, durations=[20, 40, 60]*pq.ns,
                    labels=np.array(['test epoch 1',
                                     'test epoch 2',
                                     'test epoch 3'], dtype='S'),
                    name='test', description='tester',
                    file_origin='test.file',
                    test1=1, **params)
        epc.annotate(test1=1.1, test0=[1, 2])
        assert_neo_object_is_compliant(epc)

        segment = Segment(name='seg1')
        segment.epochs = [epc]
        segment.create_many_to_one_relationship()

        self.assertEqual(epc._single_parent_objects, ('Segment',))
        self.assertEqual(epc._multi_parent_objects, ())

        self.assertEqual(epc._single_parent_containers, ('segment',))
        self.assertEqual(epc._multi_parent_containers, ())

        self.assertEqual(epc._parent_objects, ('Segment',))
        self.assertEqual(epc._parent_containers, ('segment',))

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

        assert_neo_object_is_compliant(epc)
开发者ID:Silmathoron,项目名称:python-neo,代码行数:29,代码来源:test_epoch.py


示例3: test_as_quantity

 def test_as_quantity(self):
     times = [2, 3, 4, 5]
     durations = [0.1, 0.2, 0.3, 0.4]
     epc = Epoch(times * pq.ms, durations=durations * pq.ms)
     epc_as_q = epc.as_quantity()
     self.assertIsInstance(epc_as_q, pq.Quantity)
     assert_array_equal(times * pq.ms, epc_as_q)
开发者ID:CINPLA,项目名称:python-neo,代码行数:7,代码来源:test_epoch.py


示例4: test__time_slice

    def test__time_slice(self):
        epc = Epoch(times=[10, 20, 30] * pq.s, durations=[10, 5, 7] * pq.ms,
                    labels=np.array(['btn0', 'btn1', 'btn2'], dtype='S'),
                    foo='bar')

        epc2 = epc.time_slice(10 * pq.s, 20 * pq.s)
        assert_arrays_equal(epc2.times, [10, 20] * pq.s)
        assert_arrays_equal(epc2.durations, [10, 5] * pq.ms)
        assert_arrays_equal(epc2.labels, np.array(['btn0','btn1'], dtype='S'))
        self.assertEqual(epc.annotations, epc2.annotations)
开发者ID:CINPLA,项目名称:python-neo,代码行数:10,代码来源:test_epoch.py


示例5: test__pretty

    def test__pretty(self):
        epc = Epoch([1.1, 1.5, 1.7] * pq.ms, durations=[20, 40, 60] * pq.ns,
                    labels=np.array(['test epoch 1', 'test epoch 2', 'test epoch 3'], dtype='S'),
                    name='test', description='tester', file_origin='test.file')
        epc.annotate(test1=1.1, test0=[1, 2])
        assert_neo_object_is_compliant(epc)

        prepr = pretty(epc)
        targ = ("Epoch\nname: '%s'\ndescription: '%s'\nannotations: %s"
                "" % (epc.name, epc.description, pretty(epc.annotations)))

        self.assertEqual(prepr, targ)
开发者ID:INM-6,项目名称:python-neo,代码行数:12,代码来源:test_epoch.py


示例6: test__pretty

    def test__pretty(self):
        epc = Epoch(1.5*pq.ms, duration=20*pq.ns,
                    label='test epoch', name='test', description='tester',
                    file_origin='test.file')
        epc.annotate(targ1=1.1, targ0=[1])
        assert_neo_object_is_compliant(epc)

        prepr = pretty(epc)
        targ = ("Epoch\nname: '%s'\ndescription: '%s'\nannotations: %s" %
                (epc.name, epc.description, pretty(epc.annotations)))

        self.assertEqual(prepr, targ)
开发者ID:ChrisNolan1992,项目名称:python-neo,代码行数:12,代码来源:test_epoch.py


示例7: test__time_slice

    def test__time_slice(self):
        arr_ann = {'index': np.arange(3), 'test': ['a', 'b', 'c']}
        epc = Epoch(times=[10, 20, 30] * pq.s, durations=[10, 5, 7] * pq.ms,
                    labels=np.array(['btn0', 'btn1', 'btn2'], dtype='S'), foo='bar',
                    array_annotations=arr_ann)

        epc2 = epc.time_slice(10 * pq.s, 20 * pq.s)
        assert_arrays_equal(epc2.times, [10, 20] * pq.s)
        assert_arrays_equal(epc2.durations, [10, 5] * pq.ms)
        assert_arrays_equal(epc2.labels, np.array(['btn0', 'btn1'], dtype='S'))
        self.assertEqual(epc.annotations, epc2.annotations)
        assert_arrays_equal(epc2.array_annotations['index'], np.arange(2))
        assert_arrays_equal(epc2.array_annotations['test'], np.array(['a', 'b']))
        self.assertIsInstance(epc2.array_annotations, ArrayDict)
开发者ID:INM-6,项目名称:python-neo,代码行数:14,代码来源:test_epoch.py


示例8: test_Epoch_repr

    def test_Epoch_repr(self):
        params = {'test2': 'y1', 'test3': True}
        epc = Epoch([1.1, 1.5, 1.7] * pq.ms, durations=[20, 40, 60] * pq.ns,
                    labels=np.array(['test epoch 1', 'test epoch 2', 'test epoch 3'], dtype='S'),
                    name='test', description='tester', file_origin='test.file', test1=1, **params)
        epc.annotate(test1=1.1, test0=[1, 2])
        assert_neo_object_is_compliant(epc)

        targ = ('<Epoch: test epoch [email protected] ms for 20.0 ns, '
                + 'test epoch [email protected] ms for 40.0 ns, '
                + 'test epoch [email protected] ms for 60.0 ns>')

        res = repr(epc)

        self.assertEqual(targ, res)
开发者ID:INM-6,项目名称:python-neo,代码行数:15,代码来源:test_epoch.py


示例9: test_time_slice_differnt_units

    def test_time_slice_differnt_units(self):
        params = {'test2': 'y1', 'test3': True}
        epc = Epoch([1.1, 1.5, 1.7]*pq.ms, durations=[20, 40, 60]*pq.ns,
                    labels=np.array(['test epoch 1',
                                     'test epoch 2',
                                     'test epoch 3'], dtype='S'),
                    name='test', description='tester',
                    file_origin='test.file',
                    test1=1, **params)
        epc.annotate(test1=1.1, test0=[1, 2])
        assert_neo_object_is_compliant(epc)

        targ = Epoch([1.5]*pq.ms, durations=[40]*pq.ns,
                    labels=np.array(['test epoch 2'], dtype='S'),
                    name='test', description='tester',
                    file_origin='test.file',
                    test1=1, **params)
        targ.annotate(test1=1.1, test0=[1, 2])
        assert_neo_object_is_compliant(targ)
        
        t_start = 0.0012  * pq.s
        t_stop = 0.0016 * pq.s
        result = epc.time_slice(t_start, t_stop)

        assert_arrays_equal(result.times, targ.times)
        assert_arrays_equal(result.durations, targ.durations)
        assert_arrays_equal(result.labels, targ.labels)
        self.assertEqual(result.name, targ.name)
        self.assertEqual(result.description, targ.description)
        self.assertEqual(result.file_origin, targ.file_origin)
        self.assertEqual(result.annotations['test0'], targ.annotations['test0'])
        self.assertEqual(result.annotations['test1'], targ.annotations['test1'])
        self.assertEqual(result.annotations['test2'], targ.annotations['test2'])
开发者ID:CINPLA,项目名称:python-neo,代码行数:33,代码来源:test_epoch.py


示例10: test_time_slice_empty

    def test_time_slice_empty(self):
        params = {'test2': 'y1', 'test3': True}
        epc = Epoch([]*pq.ms, durations=[]*pq.ns,
                    labels=np.array([], dtype='S'),
                    name='test', description='tester',
                    file_origin='test.file',
                    test1=1, **params)
        epc.annotate(test1=1.1, test0=[1, 2])
        assert_neo_object_is_compliant(epc)

        targ = Epoch([]*pq.ms, durations=[]*pq.ns,
                    labels=np.array([], dtype='S'),
                    name='test', description='tester',
                    file_origin='test.file',
                    test1=1, **params)
        targ.annotate(test1=1.1, test0=[1, 2])
        assert_neo_object_is_compliant(targ)
        
        t_start = 1.2
        t_stop = 1.6
        result = epc.time_slice(t_start, t_stop)

        assert_arrays_equal(result.times, targ.times)
        assert_arrays_equal(result.durations, targ.durations)
        assert_arrays_equal(result.labels, targ.labels)
        self.assertEqual(result.name, targ.name)
        self.assertEqual(result.description, targ.description)
        self.assertEqual(result.file_origin, targ.file_origin)
        self.assertEqual(result.annotations['test0'], targ.annotations['test0'])
        self.assertEqual(result.annotations['test1'], targ.annotations['test1'])
        self.assertEqual(result.annotations['test2'], targ.annotations['test2'])
开发者ID:CINPLA,项目名称:python-neo,代码行数:31,代码来源:test_epoch.py


示例11: test_time_slice_none_both

    def test_time_slice_none_both(self):
        params = {'test2': 'y1', 'test3': True}
        arr_ann = {'index': np.arange(3), 'test': ['a', 'b', 'c']}
        epc = Epoch([1.1, 1.5, 1.7] * pq.ms, durations=[20, 40, 60] * pq.ns,
                    labels=np.array(['test epoch 1', 'test epoch 2', 'test epoch 3'], dtype='S'),
                    name='test', description='tester', file_origin='test.file', test1=1,
                    array_annotations=arr_ann, **params)
        epc.annotate(test1=1.1, test0=[1, 2])
        assert_neo_object_is_compliant(epc)

        targ = Epoch([1.1, 1.5, 1.7] * pq.ms, durations=[20, 40, 60] * pq.ns,
                     labels=np.array(['test epoch 1', 'test epoch 2', 'test epoch 3'], dtype='S'),
                     name='test', description='tester', file_origin='test.file', test1=1,
                     array_annotations=arr_ann, **params)
        targ.annotate(test1=1.1, test0=[1, 2])
        assert_neo_object_is_compliant(targ)

        t_start = None
        t_stop = None
        result = epc.time_slice(t_start, t_stop)

        assert_arrays_equal(result.times, targ.times)
        assert_arrays_equal(result.durations, targ.durations)
        assert_arrays_equal(result.labels, targ.labels)
        self.assertEqual(result.name, targ.name)
        self.assertEqual(result.description, targ.description)
        self.assertEqual(result.file_origin, targ.file_origin)
        self.assertEqual(result.annotations['test0'], targ.annotations['test0'])
        self.assertEqual(result.annotations['test1'], targ.annotations['test1'])
        self.assertEqual(result.annotations['test2'], targ.annotations['test2'])
        assert_arrays_equal(result.array_annotations['index'], np.array([0, 1, 2]))
        assert_arrays_equal(result.array_annotations['test'], np.array(['a', 'b', 'c']))
        self.assertIsInstance(result.array_annotations, ArrayDict)
开发者ID:INM-6,项目名称:python-neo,代码行数:33,代码来源:test_epoch.py


示例12: test_Epoch_merge

    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,代码行数:44,代码来源:test_epoch.py


示例13: test_epoch_creation

    def test_epoch_creation(self):
        params = {'test2': 'y1', 'test3': True}
        epc = Epoch(1.5*pq.ms, duration=20*pq.ns,
                    label='test epoch', name='test', description='tester',
                    file_origin='test.file',
                    test1=1, **params)
        epc.annotate(test1=1.1, test0=[1, 2])
        assert_neo_object_is_compliant(epc)

        self.assertEqual(epc.time, 1.5*pq.ms)
        self.assertEqual(epc.duration, 20*pq.ns)
        self.assertEqual(epc.label, 'test epoch')
        self.assertEqual(epc.name, 'test')
        self.assertEqual(epc.description, 'tester')
        self.assertEqual(epc.file_origin, 'test.file')
        self.assertEqual(epc.annotations['test0'], [1, 2])
        self.assertEqual(epc.annotations['test1'], 1.1)
        self.assertEqual(epc.annotations['test2'], 'y1')
        self.assertTrue(epc.annotations['test3'])
开发者ID:ChrisNolan1992,项目名称:python-neo,代码行数:19,代码来源:test_epoch.py


示例14: test_Epoch_merge

    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,代码行数:41,代码来源:test_epoch.py


示例15: test__children

    def test__children(self):
        params = {'testarg2': 'yes', 'testarg3': True}
        epc = Epoch(1.5*pq.ms, duration=20*pq.ns,
                    label='test epoch', name='test', description='tester',
                    file_origin='test.file',
                    testarg1=1, **params)
        epc.annotate(testarg1=1.1, testarg0=[1, 2, 3])
        assert_neo_object_is_compliant(epc)

        segment = Segment(name='seg1')
        segment.epochs = [epc]
        segment.create_many_to_one_relationship()

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

        self.assertEqual(epc._single_child_objects, ())

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

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

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

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


示例16: test_Epoch_creation

    def test_Epoch_creation(self):
        params = {'test2': 'y1', 'test3': True}
        epc = Epoch([1.1, 1.5, 1.7]*pq.ms, durations=[20, 40, 60]*pq.ns,
                    labels=np.array(['test epoch 1',
                                     'test epoch 2',
                                     'test epoch 3'], dtype='S'),
                    name='test', description='tester',
                    file_origin='test.file',
                    test1=1, **params)
        epc.annotate(test1=1.1, test0=[1, 2])
        assert_neo_object_is_compliant(epc)

        assert_arrays_equal(epc.times, [1.1, 1.5, 1.7]*pq.ms)
        assert_arrays_equal(epc.durations, [20, 40, 60]*pq.ns)
        assert_arrays_equal(epc.labels, np.array(['test epoch 1',
                                                  'test epoch 2',
                                                  'test epoch 3'], dtype='S'))
        self.assertEqual(epc.name, 'test')
        self.assertEqual(epc.description, 'tester')
        self.assertEqual(epc.file_origin, 'test.file')
        self.assertEqual(epc.annotations['test0'], [1, 2])
        self.assertEqual(epc.annotations['test1'], 1.1)
        self.assertEqual(epc.annotations['test2'], 'y1')
        self.assertTrue(epc.annotations['test3'])
开发者ID:Silmathoron,项目名称:python-neo,代码行数:24,代码来源:test_epoch.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python event.Event类代码示例发布时间:2022-05-27
下一篇:
Python baseneo.BaseNeo类代码示例发布时间: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