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


Python Block.channel_indexes方法代码示例

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


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

示例1: test__construct_subsegment_by_unit

# 需要导入模块: from neo.core import Block [as 别名]
# 或者: from neo.core.Block import channel_indexes [as 别名]
    def test__construct_subsegment_by_unit(self):
        nb_seg = 3
        nb_unit = 7
        unit_with_sig = np.array([0, 2, 5])
        signal_types = ['Vm', 'Conductances']
        sig_len = 100

        # channelindexes
        chxs = [ChannelIndex(name='Vm',
                             index=unit_with_sig),
                ChannelIndex(name='Conductance',
                             index=unit_with_sig)]

        # Unit
        all_unit = []
        for u in range(nb_unit):
            un = Unit(name='Unit #%d' % u, channel_indexes=np.array([u]))
            assert_neo_object_is_compliant(un)
            all_unit.append(un)

        blk = Block()
        blk.channel_indexes = chxs
        for s in range(nb_seg):
            seg = Segment(name='Simulation %s' % s)
            for j in range(nb_unit):
                st = SpikeTrain([1, 2], units='ms',
                                t_start=0., t_stop=10)
                st.unit = all_unit[j]

            for t in signal_types:
                anasigarr = AnalogSignal(np.zeros((sig_len,
                                                        len(unit_with_sig))),
                                              units='nA',
                                              sampling_rate=1000.*pq.Hz,
                                              channel_indexes=unit_with_sig)
                seg.analogsignals.append(anasigarr)

        blk.create_many_to_one_relationship()
        for unit in all_unit:
            assert_neo_object_is_compliant(unit)
        for chx in chxs:
            assert_neo_object_is_compliant(chx)
        assert_neo_object_is_compliant(blk)

        # what you want
        newseg = seg.construct_subsegment_by_unit(all_unit[:4])
        assert_neo_object_is_compliant(newseg)
开发者ID:msenoville,项目名称:python-neo,代码行数:49,代码来源:test_segment.py

示例2: test__children

# 需要导入模块: from neo.core import Block [as 别名]
# 或者: from neo.core.Block import channel_indexes [as 别名]
    def test__children(self):
        blk = Block(name='block1')
        blk.channel_indexes = [self.chx1]
        blk.create_many_to_one_relationship()

        self.assertEqual(self.chx1._container_child_objects, ('Unit',))
        self.assertEqual(self.chx1._data_child_objects, ('AnalogSignal', 'IrregularlySampledSignal'))
        self.assertEqual(self.chx1._single_parent_objects, ('Block',))
        self.assertEqual(self.chx1._multi_child_objects, tuple())
        self.assertEqual(self.chx1._multi_parent_objects, ())
        self.assertEqual(self.chx1._child_properties, ())

        self.assertEqual(self.chx1._single_child_objects,
                         ('Unit', 'AnalogSignal', 'IrregularlySampledSignal'))

        self.assertEqual(self.chx1._container_child_containers, ('units',))
        self.assertEqual(self.chx1._data_child_containers,
                         ('analogsignals', 'irregularlysampledsignals'))
        self.assertEqual(self.chx1._single_child_containers,
                         ('units', 'analogsignals', 'irregularlysampledsignals'))
        self.assertEqual(self.chx1._single_parent_containers, ('block',))
        self.assertEqual(self.chx1._multi_child_containers,
                         tuple())
        self.assertEqual(self.chx1._multi_parent_containers, ())

        self.assertEqual(self.chx1._child_objects,
                         ('Unit', 'AnalogSignal', 'IrregularlySampledSignal'))
        self.assertEqual(self.chx1._child_containers,
                         ('units', 'analogsignals', 'irregularlysampledsignals'))
        self.assertEqual(self.chx1._parent_objects, ('Block',))
        self.assertEqual(self.chx1._parent_containers, ('block',))

        self.assertEqual(len(self.chx1._single_children), 3*self.nchildren)
        self.assertEqual(len(self.chx1._multi_children), 0)
        self.assertEqual(len(self.chx1.data_children), 2*self.nchildren)
        self.assertEqual(len(self.chx1.data_children_recur),
                         2*self.nchildren + 1*self.nchildren**2)
        self.assertEqual(len(self.chx1.container_children), 1*self.nchildren)
        self.assertEqual(len(self.chx1.container_children_recur),
                         1*self.nchildren)
        self.assertEqual(len(self.chx1.children), 3*self.nchildren)
        self.assertEqual(len(self.chx1.children_recur),
                         3*self.nchildren + 1*self.nchildren**2)

        assert_same_sub_schema(list(self.chx1._single_children),
                               self.units1a + self.sigarrs1a + self.irrsig1a,
                               exclude=['channel_index'])


        assert_same_sub_schema(list(self.chx1.data_children), self.sigarrs1a + self.irrsig1a,
                               exclude=['channel_index'])
        assert_same_sub_schema(list(self.chx1.data_children_recur),
                               self.sigarrs1a + self.irrsig1a +
                               self.trains1[:2] + self.trains1[2:],
                               exclude=['channel_index'])

        assert_same_sub_schema(list(self.chx1.children),
                               self.sigarrs1a + self.irrsig1a + self.units1a,
                               exclude=['channel_index'])
        assert_same_sub_schema(list(self.chx1.children_recur),
                               self.sigarrs1a + self.irrsig1a +
                               self.trains1[:2] + self.trains1[2:] +
                               self.units1a,
                               exclude=['channel_index'])

        self.assertEqual(len(self.chx1.parents), 1)
        self.assertEqual(self.chx1.parents[0].name, 'block1')
开发者ID:msenoville,项目名称:python-neo,代码行数:69,代码来源:test_channelindex.py


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