def _Start(self): """ Method that can be used from derived classes to start the averaging process. """ self.Clear() self.__TriggerTrigger(0) sumpf.activate_output(self.TriggerDataCreation) for i in range(1, self.__number): self.__TriggerTrigger(i) sumpf.deactivate_output(self.TriggerDataCreation)
def prepare_for_loading(): total_length = self.__properties.GetSignalLength() ratio = float(self.__sweep_duration.GetLength()) / float(self.__concatenation.GetOutputLength()) sweep_length = total_length * ratio sumpf.deactivate_output(self.__concatenation.GetOutput) self.__playback_fft.SetSignal.NoticeAnnouncement(self.__concatenation.GetOutput) sumpf.activate_output(self.__properties) self.__sweep_duration.SetDuration(sweep_length / self.__properties.GetSamplingRate()) self.__silence_duration.SetDuration((total_length - sweep_length) / self.__properties.GetSamplingRate()) self.__record_fft.SetSignal(sumpf.modules.ConstantSignalGenerator(value=0.0, samplingrate=self.__properties.GetSamplingRate(), length=total_length).GetSignal()) sumpf.activate_output(self.__concatenation.GetOutput)
def Clear(self): """ Removes all kept spectrums. """ sumpf.deactivate_output(self.__merge_utf) while self.__kept_ids != []: data_id = self.__kept_ids.pop() self.__merge_utf.RemoveInput(data_id) self.ShowRecent(True) self.__progress_indicator.AddMethod(self.__ifft.SetSpectrum) sumpf.activate_output(self.__merge_utf)
def SetNormalize(self, normalize, individual=False, frequency=1000.0): """ @param normalize: False, to disable normalization, "average" to normalize to average, "frequency" to normalize to frequency """ sumpf.deactivate_output(self.__bypass_normalize.GetOutput) if normalize in ("average", "frequency"): method_pairs = [(self.__bypass_normalize.SetSelection, self.__NORMALIZE)] if normalize == "average": method_pairs.append((self.__select_normalization.SetSelection, self.__AVERAGE)) method_pairs.append((self.__normalize_avg.SetIndividual, individual)) else: method_pairs.append((self.__select_normalization.SetSelection, self.__FREQUENCY)) method_pairs.append((self.__normalize_frq.SetFrequency, frequency)) sumpf.set_multiple_values(pairs=method_pairs, progress_indicator=self.__progress_indicator) else: self.__bypass_normalize.SetSelection(self.__BYPASS) sumpf.activate_output(self.__bypass_normalize.GetOutput)
def test_duplicate_calculation(self): """ Tests if duplicate calculation in forked chains is avoided. """ sumpf.connect(self.obj1.GetValue, self.obj2.SetValue) sumpf.connect(self.obj1.GetValue, self.obj2.SetValue2) sumpf.connect(self.obj2.GetValue, self.obj1.SetValueNoUpdate) self.obj2.history = [] self.obj1.SetValue(1) self.assertEqual(self.obj2.history, [1]) # the value should have been calculated only once sumpf.deactivate_output(self.obj1) self.obj2.history = [] self.obj1.SetValue(2) sumpf.activate_output(self.obj1) self.assertEqual(self.obj2.history, [2]) # the value should have been calculated only once after reactivating outputs sumpf.disconnect_all(self.obj1) sumpf.connect(self.obj1.GetValue, self.obj2.AddItemNoReplace) sumpf.connect(self.obj1.GetValue2, self.obj2.AddItemNoReplace) sumpf.connect(self.obj2.GetItems, self.obj1.TakeList) self.obj2.history = [] self.obj1.SetValue2(3) self.assertEqual(self.obj2.history, [[3, 6]]) # the list should have been calculated only once
def test_deactivate_output(self): """ Tests if deactivating and reactivating outputs works. """ self.obj1.SetValue(0) self.obj2.SetValue(1) sumpf.deactivate_output(self.obj1.GetValue) sumpf.connect(self.obj1.GetValue, self.obj2.SetValue) self.assertEqual(self.obj2.GetValue(), 1) # A deactivated output shall not be passed while creating a connection sumpf.activate_output(self.obj1.GetValue) sumpf.connect(self.obj1.GetText, self.obj2.SetText) self.obj1.ComputeValueAndText(2) sumpf.deactivate_output(self.obj1) sumpf.deactivate_output(self.obj1) # Deactivating already deactivated outputs should not fail self.obj1.ComputeValueAndText(3) self.assertEqual(self.obj2.GetValue(), 2) # No value should be passed through deactivated outputs sumpf.activate_output(self.obj1.GetValue) self.assertEqual(self.obj2.GetValue(), 3) # Value should have been passed through reactivated output self.assertEqual(self.obj2.GetText(), "2") # Text output should have remained deactivated sumpf.activate_output(self.obj1) self.assertEqual(self.obj2.GetText(), "3") # Text should have been passed while globally enabling outputs
def __Unload(self, merger, id_dict, filenames): sumpf.deactivate_output(merger.GetOutput) for f in filenames: data_id = id_dict.pop(f) merger.RemoveInput(data_id) sumpf.activate_output(merger.GetOutput)