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


Python AnalogSignal.channel_index方法代码示例

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


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

示例1: test__pickle

# 需要导入模块: from neo.core.analogsignal import AnalogSignal [as 别名]
# 或者: from neo.core.analogsignal.AnalogSignal import channel_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__slice_should_modify_linked_channelindex

# 需要导入模块: from neo.core.analogsignal import AnalogSignal [as 别名]
# 或者: from neo.core.analogsignal.AnalogSignal import channel_index [as 别名]
 def test__slice_should_modify_linked_channelindex(self):
     n = 8  # number of channels
     signal = AnalogSignal(np.arange(n * 100.0).reshape(100, n),
                           sampling_rate=1*pq.kHz,
                           units="mV")
     self.assertEqual(signal.shape, (100, n))
     signal.channel_index = ChannelIndex(index=np.arange(n, dtype=int),
                                         channel_names=["channel{0}".format(i) for i in range(n)])
     odd_channels = signal[:, 1::2]
     self.assertEqual(odd_channels.shape, (100, n//2))
     assert_array_equal(odd_channels.channel_index.index, np.arange(n//2, dtype=int))
     assert_array_equal(odd_channels.channel_index.channel_names, ["channel{0}".format(i) for i in range(1, n, 2)])
     assert_array_equal(signal.channel_index.channel_names, ["channel{0}".format(i) for i in range(n)])
开发者ID:mpsonntag,项目名称:python-neo,代码行数:15,代码来源:test_analogsignal.py

示例3: test__pickle

# 需要导入模块: from neo.core.analogsignal import AnalogSignal [as 别名]
# 或者: from neo.core.analogsignal.AnalogSignal import channel_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])

        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]))
        fobj.close()
        os.remove('./pickle')
开发者ID:msenoville,项目名称:python-neo,代码行数:22,代码来源:test_analogsignal.py


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