From: Thomas Fillon Date: Mon, 7 Oct 2013 16:40:00 +0000 (+0200) Subject: Simplify Analyzer Result container naming X-Git-Tag: 0.5.0~45^2 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=1253e5b0545c615fdfcd896223356dbcd92ff2b4;p=timeside.git Simplify Analyzer Result container naming --- diff --git a/doc/slides/timeside_slides.html b/doc/slides/timeside_slides.html index 8dc0e9b..923a205 100644 --- a/doc/slides/timeside_slides.html +++ b/doc/slides/timeside_slides.html @@ -358,10 +358,10 @@ class AnalyzerResultContainer(object): if a != b: return False return True - def add_result(self, analyzer_result): + def add(self, analyzer_result): if type(analyzer_result) == list: for a in analyzer_result: - self.add_result(a) + self.add(a) return if type(analyzer_result) != AnalyzerResult: raise TypeError('only AnalyzerResult can be added') @@ -483,7 +483,7 @@ class NewAnalyzer(Processor): result = AnalyzerResult(id = self.id(), name = self.name(), unit = "something") result.value = self.result_data - container.add_result(result) + container.add(result) # add other results in the container if needed... diff --git a/timeside/analyzer/aubio_melenergy.py b/timeside/analyzer/aubio_melenergy.py index ae56071..68945e7 100644 --- a/timeside/analyzer/aubio_melenergy.py +++ b/timeside/analyzer/aubio_melenergy.py @@ -78,5 +78,5 @@ class AubioMelEnergy(Analyzer): # Set Data melenergy.data.value = self.melenergy_results - self.resultContainer.add_result(melenergy) + self._results.add(melenergy) diff --git a/timeside/analyzer/aubio_mfcc.py b/timeside/analyzer/aubio_mfcc.py index 2c302c0..987d8b5 100644 --- a/timeside/analyzer/aubio_mfcc.py +++ b/timeside/analyzer/aubio_mfcc.py @@ -77,4 +77,4 @@ class AubioMfcc(Analyzer): mfcc.parameters = parameters mfcc.data.value = self.mfcc_results - self.resultContainer.add_result(mfcc) + self._results.add(mfcc) diff --git a/timeside/analyzer/aubio_pitch.py b/timeside/analyzer/aubio_pitch.py index b778a9a..face938 100644 --- a/timeside/analyzer/aubio_pitch.py +++ b/timeside/analyzer/aubio_pitch.py @@ -78,5 +78,5 @@ class AubioPitch(Analyzer): # Set Data pitch.data.value = numpy.array(self.pitches) - self.resultContainer.add_result(pitch) + self._results.add(pitch) diff --git a/timeside/analyzer/aubio_specdesc.py b/timeside/analyzer/aubio_specdesc.py index 72491cd..c7594eb 100644 --- a/timeside/analyzer/aubio_specdesc.py +++ b/timeside/analyzer/aubio_specdesc.py @@ -83,5 +83,5 @@ class AubioSpecdesc(Analyzer): res_specdesc.data.value = self.specdesc_results[method] - self.resultContainer.add_result(res_specdesc) + self._results.add(res_specdesc) diff --git a/timeside/analyzer/aubio_temporal.py b/timeside/analyzer/aubio_temporal.py index 79bf78f..24ca77e 100644 --- a/timeside/analyzer/aubio_temporal.py +++ b/timeside/analyzer/aubio_temporal.py @@ -89,7 +89,7 @@ class AubioTemporal(Analyzer): onsets.labelMetadata.label = {1: 'Onset'} - self.resultContainer.add_result(onsets) + self._results.add(onsets) #--------------------------------- # Onset Rate @@ -109,7 +109,7 @@ class AubioTemporal(Analyzer): else: onsetrate.data.value = [] - self.resultContainer.add_result(onsetrate) + self._results.add(onsetrate) #--------------------------------- # Beats @@ -133,7 +133,7 @@ class AubioTemporal(Analyzer): beats.labelMetadata.label = {1: 'Beat'} - self.resultContainer.add_result(beats) + self._results.add(beats) #--------------------------------- # BPM @@ -156,4 +156,4 @@ class AubioTemporal(Analyzer): else: bpm.data.value = [] - self.resultContainer.add_result(bpm) + self._results.add(bpm) diff --git a/timeside/analyzer/core.py b/timeside/analyzer/core.py index aaef5f2..2fc9497 100644 --- a/timeside/analyzer/core.py +++ b/timeside/analyzer/core.py @@ -597,7 +597,7 @@ class AnalyzerResultContainer(dict): def __init__(self, analyzer_results=None): super(AnalyzerResultContainer,self).__init__() if analyzer_results is not None: - self.add_result(analyzer_results) + self.add(analyzer_results) # def __getitem__(self, i): # return self.results[i] @@ -616,10 +616,10 @@ class AnalyzerResultContainer(dict): #def __ne__(self, other): # return not self.__eq__(other) - def add_result(self, analyzer_result): + def add(self, analyzer_result): if isinstance(analyzer_result, list): for res in analyzer_result: - self.add_result(res) + self.add(res) return # Check result if not isinstance(analyzer_result, AnalyzerResult): @@ -651,7 +651,7 @@ class AnalyzerResultContainer(dict): root = ET.fromstring(xml_string) for child in root.iter('result'): result = AnalyzerResult() - results.add_result(result.from_xml(ET.tostring(child))) + results.add(result.from_xml(ET.tostring(child))) return results @@ -691,7 +691,7 @@ class AnalyzerResultContainer(dict): if key not in ['dataMode', 'timeMode']: res[key] = res_json[key] - results.add_result(res) + results.add(res) return results def to_yaml(self): @@ -724,7 +724,7 @@ class AnalyzerResultContainer(dict): res = AnalyzerResult() for key in res_yaml.keys(): res[key] = res_yaml[key] - results.add_result(res) + results.add(res) return results def to_numpy(self, output_file): @@ -806,7 +806,7 @@ class AnalyzerResultContainer(dict): else: result[subgroup_name][dsetName] = [] - data_list.add_result(result) + data_list.add(result) except TypeError: print('TypeError for HDF5 serialization') finally: @@ -837,8 +837,8 @@ class Analyzer(Processor): self.result_stepsize = self.input_stepsize def results(self): - #container = AnalyzerResultContainer() - return self.resultContainer + #TODO :return self._results[id=analyzerID] + return self._results @staticmethod @interfacedoc diff --git a/timeside/analyzer/dc.py b/timeside/analyzer/dc.py index 5374257..da8fe5e 100644 --- a/timeside/analyzer/dc.py +++ b/timeside/analyzer/dc.py @@ -55,4 +55,4 @@ class MeanDCShift(Analyzer): dc_result.idMetadata.unit = "%" # Set Data dc_result.data.value = numpy.round(numpy.mean(100*self.values),3) - self.resultContainer.add_result(dc_result) \ No newline at end of file + self._results.add(dc_result) \ No newline at end of file diff --git a/timeside/analyzer/level.py b/timeside/analyzer/level.py index bcfc1d1..bf406ab 100644 --- a/timeside/analyzer/level.py +++ b/timeside/analyzer/level.py @@ -69,7 +69,7 @@ class Level(Analyzer): max_level.idMetadata.unit = "dBFS" max_level.data.value = numpy.round(20*numpy.log10(self.max_value), 3) - self.resultContainer.add_result(max_level) + self._results.add(max_level) # RMS level rms_level = self.new_result(dataMode='value', timeMode='global') @@ -79,5 +79,5 @@ class Level(Analyzer): rms_level.data.value = numpy.round(20*numpy.log10( numpy.sqrt(numpy.mean(self.mean_values))), 3) - self.resultContainer.add_result(rms_level) + self._results.add(rms_level) diff --git a/timeside/analyzer/yaafe.py b/timeside/analyzer/yaafe.py index 0ee83fe..e2fbaf8 100644 --- a/timeside/analyzer/yaafe.py +++ b/timeside/analyzer/yaafe.py @@ -99,6 +99,6 @@ class Yaafe(Analyzer): result.data.value = self.yaafe_engine.readOutput(featName) # Store results in Container if len(result.data.value): - self.resultContainer.add_result(result) + self._results.add(result) diff --git a/timeside/core.py b/timeside/core.py index cde3bad..b236053 100644 --- a/timeside/core.py +++ b/timeside/core.py @@ -240,7 +240,7 @@ class ProcessPipe(object): last = source from timeside.analyzer.core import AnalyzerResultContainer - self.resultContainer = AnalyzerResultContainer() + self._results = AnalyzerResultContainer() # setup/reset processors and configure properties throughout the pipe for item in items: @@ -249,7 +249,7 @@ class ProcessPipe(object): blocksize = last.blocksize(), totalframes = last.totalframes()) item.source_mediainfo = source.mediainfo() - item.resultContainer = self.resultContainer + item._results = self._results last = item # now stream audio data along the pipe