本文整理汇总了Python中neo.core.analogsignal.AnalogSignal.annotations['index']方法的典型用法代码示例。如果您正苦于以下问题:Python AnalogSignal.annotations['index']方法的具体用法?Python AnalogSignal.annotations['index']怎么用?Python AnalogSignal.annotations['index']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类neo.core.analogsignal.AnalogSignal
的用法示例。
在下文中一共展示了AnalogSignal.annotations['index']方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test__pickle
# 需要导入模块: from neo.core.analogsignal import AnalogSignal [as 别名]
# 或者: from neo.core.analogsignal.AnalogSignal import annotations['index'] [as 别名]
def test__pickle(self):
signal1 = AnalogSignal([1, 2, 3, 4], sampling_period=1 * pq.ms, units=pq.S)
signal1.annotations['index'] = 2
signal1.channel_index = ChannelIndex(index=[0])
signal1.array_annotate(**{'anno1': [23], 'anno2': ['A']})
fobj = open('./pickle', 'wb')
pickle.dump(signal1, fobj)
fobj.close()
fobj = open('./pickle', 'rb')
try:
signal2 = pickle.load(fobj)
except ValueError:
signal2 = None
assert_array_equal(signal1, signal2)
assert_array_equal(signal2.channel_index.index, np.array([0]))
assert_array_equal(signal2.array_annotations['anno1'], np.array([23]))
self.assertIsInstance(signal2.array_annotations, ArrayDict)
# Make sure the dict can perform correct checks after unpickling
signal2.array_annotations['anno3'] = [2]
with self.assertRaises(ValueError):
signal2.array_annotations['anno4'] = [2, 1]
fobj.close()
os.remove('./pickle')
示例2: test__pickle
# 需要导入模块: from neo.core.analogsignal import AnalogSignal [as 别名]
# 或者: from neo.core.analogsignal.AnalogSignal import annotations['index'] [as 别名]
def test__pickle(self):
a = AnalogSignal([1,2,3,4],sampling_period=1*pq.ms,units=pq.S)
a.annotations['index'] = 2
f = open('./pickle','wb')
pickle.dump(a,f)
f.close()
f = open('./pickle','rb')
try:
b = pickle.load(f)
except ValueError:
b = None
assert_arrays_equal(a, b)
f.close()
os.remove('./pickle')
示例3: test__pickle
# 需要导入模块: from neo.core.analogsignal import AnalogSignal [as 别名]
# 或者: from neo.core.analogsignal.AnalogSignal import annotations['index'] [as 别名]
def test__pickle(self):
signal1 = AnalogSignal([1, 2, 3, 4], sampling_period=1*pq.ms,
units=pq.S)
signal1.annotations['index'] = 2
fobj = open('./pickle', 'wb')
pickle.dump(signal1, fobj)
fobj.close()
fobj = open('./pickle', 'rb')
try:
signal2 = pickle.load(fobj)
except ValueError:
signal2 = None
assert_array_equal(signal1, signal2)
fobj.close()
os.remove('./pickle')