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


Python AnalogSignal.annotations['index']方法代码示例

本文整理汇总了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')
开发者ID:INM-6,项目名称:python-neo,代码行数:28,代码来源:test_analogsignal.py

示例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')
开发者ID:michaelfsp,项目名称:python-neo,代码行数:19,代码来源:test_analogsignal.py

示例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')
开发者ID:CINPLA,项目名称:python-neo,代码行数:20,代码来源:test_analogsignal.py


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