本文整理汇总了Python中neo.core.epoch.Epoch.time_slice方法的典型用法代码示例。如果您正苦于以下问题:Python Epoch.time_slice方法的具体用法?Python Epoch.time_slice怎么用?Python Epoch.time_slice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类neo.core.epoch.Epoch
的用法示例。
在下文中一共展示了Epoch.time_slice方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_time_slice_differnt_units
# 需要导入模块: from neo.core.epoch import Epoch [as 别名]
# 或者: from neo.core.epoch.Epoch import time_slice [as 别名]
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'])
示例2: test_time_slice_empty
# 需要导入模块: from neo.core.epoch import Epoch [as 别名]
# 或者: from neo.core.epoch.Epoch import time_slice [as 别名]
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'])
示例3: test_time_slice_none_both
# 需要导入模块: from neo.core.epoch import Epoch [as 别名]
# 或者: from neo.core.epoch.Epoch import time_slice [as 别名]
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)
示例4: test__time_slice
# 需要导入模块: from neo.core.epoch import Epoch [as 别名]
# 或者: from neo.core.epoch.Epoch import time_slice [as 别名]
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)
示例5: test__time_slice
# 需要导入模块: from neo.core.epoch import Epoch [as 别名]
# 或者: from neo.core.epoch.Epoch import time_slice [as 别名]
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)