當前位置: 首頁>>代碼示例>>Python>>正文


Python StimulusModel.contains方法代碼示例

本文整理匯總了Python中sparkle.stim.stimulus_model.StimulusModel.contains方法的典型用法代碼示例。如果您正苦於以下問題:Python StimulusModel.contains方法的具體用法?Python StimulusModel.contains怎麽用?Python StimulusModel.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sparkle.stim.stimulus_model.StimulusModel的用法示例。


在下文中一共展示了StimulusModel.contains方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TestStimModel

# 需要導入模塊: from sparkle.stim.stimulus_model import StimulusModel [as 別名]
# 或者: from sparkle.stim.stimulus_model.StimulusModel import contains [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.contains方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。