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


Python Event.time_slice方法代码示例

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


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

示例1: test__time_slice

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

示例2: test_time_slice_differnt_units

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

示例3: test_time_slice_differnt_units

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

示例4: test_time_slice_empty

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

示例5: test_time_slice_out_of_boundries

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

示例6: test_time_slice_empty

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

示例7: tests_time_slice

# 需要导入模块: from neo.core.event import Event [as 别名]
# 或者: from neo.core.event.Event import time_slice [as 别名]
    def tests_time_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.time_slice(t_start=2.0, t_stop=3.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'])
        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,代码行数:24,代码来源:test_event.py


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