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


Python StimulusModel.overwriteComponent方法代码示例

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


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

示例1: TestStimModel

# 需要导入模块: from sparkle.stim.stimulus_model import StimulusModel [as 别名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import overwriteComponent [as 别名]
class TestStimModel():
    def setup(self):
        self.model = StimulusModel()
        self.model.setReferenceVoltage(100, 0.1)
        self.model.setMaxVoltage(MAXV, DEVICE_MAXV)
        self.model.setMinVoltage(0.005)

    def test_insert_data(self):
        fake_component0 = 'ducks'
        fake_component1 = 'frogs'
        self.model.insertComponent(fake_component0, 0, 0)
        self.model.insertComponent(fake_component1, 0, 0)
        assert self.model.component(0,0) == fake_component1
        assert self.model.component(0,1) == fake_component0

    def test_remove_data(self):
        fake_component0 = 'ducks'
        self.model.insertComponent(fake_component0, 0, 0)
        self.model.removeComponent(0,0)
        assert self.model.component(0,0) == None

    def test_component_index(self):
        fake_component0 = 'ducks'
        # component will be added to the lowest index in row
        self.model.insertComponent(fake_component0, 0, 2)
        index = self.model.indexByComponent(fake_component0)
        assert index == (0,0)

    @raises(IndexError)
    def test_set_data(self):
        fake_component0 = 'ducks'
        self.model.overwriteComponent(fake_component0, 0, 0)

    def test_row_column_count(self):
        fake_component0 = 'ducks'
        self.model.insertComponent(fake_component0, 0, 0)
        assert self.model.columnCountForRow(0) == 1
        assert self.model.rowCount() == 1

    def test_trace_count_no_auto(self):
        component0 = PureTone()
        component1 = PureTone()
        self.model.insertComponent(component0, 0,0)
        self.model.insertComponent(component1, 0,0)

        assert self.model.traceCount() == 1

    def test_trace_count_no_components(self):
        self.add_auto_param(self.model)        

        assert self.model.traceCount() == 0

    def test_trace_count_with_auto(self):
        component = PureTone()
        self.model.insertComponent(component, 0,0)     

        nsteps = self.add_auto_param(self.model)        

        assert self.model.traceCount() == nsteps

    def test_model_contains(self):
        component = PureTone()
        self.model.insertComponent(component, 0,0)

        assert self.model.contains('PureTone')

    def test_expanded_stim_no_auto(self):
        """signal of a model without any auto parameters"""
        component = PureTone()
        self.model.insertComponent(component, 0,0)

        signals, doc, ovld = self.model.expandedStim()
        assert len(signals) == 1
        assert_equal(signals[0][0].shape[0], component.duration()*self.model.samplerate())
        assert len(doc) == 1
        assert doc[0]['samplerate_da'] == self.model.samplerate()

    def test_expanded_stim_with_auto(self):
        component = PureTone()
        self.model.insertComponent(component, 0,0)       
        nsteps = self.add_auto_param(self.model)        

        signals, doc, ovld = self.model.expandedStim()
        assert len(signals) == nsteps
        assert len(doc) == nsteps
        assert doc[0]['samplerate_da'] == self.model.samplerate()

    def test_expaned_stim_with_vocal_auto(self):
        component = Vocalization()
        component.setFile(sample.samplewav())
        self.model.insertComponent(component, 0,0)       
        nsteps = self.add_vocal_param(self.model)        

        signals, doc, ovld = self.model.expandedStim()
        assert len(signals) == nsteps
        assert len(doc) == nsteps
        assert doc[0]['samplerate_da'] == self.model.samplerate()

    def test_signal_eq_caldb(self):
        caldb = 100
#.........这里部分代码省略.........
开发者ID:boylea,项目名称:sparkle,代码行数:103,代码来源:test_stim_model.py


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