From: Thomas Fillon Date: Thu, 10 Oct 2013 13:13:11 +0000 (+0200) Subject: Add @property decorator to some functions in timeside.analyzer.core X-Git-Tag: 0.5.0~37^2 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=8d7e5419f0b32fb96edb031e0d5ff1649d984cf0;p=timeside.git Add @property decorator to some functions in timeside.analyzer.core - in Analyzer results() became a property - modify tests to reflect this change - add id() and name() as property in AnalyzerResult --- diff --git a/tests/test_analyzer_dc.py b/tests/test_analyzer_dc.py index 3fd683d..65bf3d9 100755 --- a/tests/test_analyzer_dc.py +++ b/tests/test_analyzer_dc.py @@ -23,7 +23,7 @@ class TestAnalyzerDC(TestCase): def tearDown(self): decoder = FileDecoder(self.source) (decoder | self.analyzer).run() - results = self.analyzer.results() + results = self.analyzer.results for key in self.expected.keys(): self.assertEquals(results[key].dataObject.value, self.expected[key]) diff --git a/tests/test_analyzer_level.py b/tests/test_analyzer_level.py index 64fee4a..8fcf116 100755 --- a/tests/test_analyzer_level.py +++ b/tests/test_analyzer_level.py @@ -31,7 +31,7 @@ class TestAnalyzerLevel(TestCase): def tearDown(self): decoder = FileDecoder(self.source) (decoder | self.analyzer).run() - results = self.analyzer.results() + results = self.analyzer.results for key in self.expected.keys(): self.assertEquals(results[key].dataObject.value, self.expected[key]) #print results diff --git a/tests/test_aubio_melenergy.py b/tests/test_aubio_melenergy.py index b53eb64..8ee4a86 100755 --- a/tests/test_aubio_melenergy.py +++ b/tests/test_aubio_melenergy.py @@ -20,7 +20,7 @@ class TestAubioMelEnergy(TestCase): def tearDown(self): decoder = FileDecoder(self.source) (decoder | self.analyzer).run() - results = self.analyzer.results() + results = self.analyzer.results #print results #print results.to_yaml() #print results.to_json() diff --git a/tests/test_aubio_mfcc.py b/tests/test_aubio_mfcc.py index abdaad6..bc1f26c 100755 --- a/tests/test_aubio_mfcc.py +++ b/tests/test_aubio_mfcc.py @@ -20,7 +20,7 @@ class TestAubioMfcc(TestCase): def tearDown(self): decoder = FileDecoder(self.source) (decoder | self.analyzer).run() - results = self.analyzer.results() + results = self.analyzer.results #print results #print results.to_yaml() #print results.to_json() diff --git a/tests/test_aubio_pitch.py b/tests/test_aubio_pitch.py index 7c120f2..660d7d0 100755 --- a/tests/test_aubio_pitch.py +++ b/tests/test_aubio_pitch.py @@ -20,7 +20,7 @@ class TestAubioPitch(TestCase): def tearDown(self): decoder = FileDecoder(self.source) (decoder | self.analyzer).run() - results = self.analyzer.results() + results = self.analyzer.results #print "result:", self.analyzer.result() if __name__ == '__main__': diff --git a/tests/test_aubio_specdesc.py b/tests/test_aubio_specdesc.py index 4170a5c..5fb0fcf 100755 --- a/tests/test_aubio_specdesc.py +++ b/tests/test_aubio_specdesc.py @@ -20,7 +20,7 @@ class TestAubioSpecdesc(TestCase): def tearDown(self): decoder = FileDecoder(self.source) (decoder | self.analyzer).run() - results = self.analyzer.results() + results = self.analyzer.results #results.to_yaml() #results.to_json() #results.to_xml() diff --git a/tests/test_aubio_temporal.py b/tests/test_aubio_temporal.py index 423f75b..6189efb 100755 --- a/tests/test_aubio_temporal.py +++ b/tests/test_aubio_temporal.py @@ -20,7 +20,7 @@ class TestAubioTemporal(TestCase): def tearDown(self): decoder = FileDecoder(self.source) (decoder | self.analyzer).run() - results = self.analyzer.results() + results = self.analyzer.results #print results results.to_yaml() results.to_json() diff --git a/tests/test_yaafe.py b/tests/test_yaafe.py index 71dc50b..086bdee 100755 --- a/tests/test_yaafe.py +++ b/tests/test_yaafe.py @@ -65,7 +65,7 @@ class TestYaafe(TestCase): decoder = FileDecoder(self.source) decoder.output_samplerate = self.sample_rate (decoder | self.analyzer).run() - results = self.analyzer.results() + results = self.analyzer.results self.assertEquals(self.result_length, len(results)) #print results #print results.to_yaml() diff --git a/timeside/analyzer/core.py b/timeside/analyzer/core.py index 8eda851..a54a4b9 100644 --- a/timeside/analyzer/core.py +++ b/timeside/analyzer/core.py @@ -570,6 +570,7 @@ class AnalyzerResult(MetadataObject): return result + @property def data(self): if self.dataMode is None: return ( @@ -581,6 +582,7 @@ class AnalyzerResult(MetadataObject): elif self.dataMode is 'label': return self.dataObject.label + @property def time(self): if self.timeMode == 'global': return self.audioMetadata.start @@ -593,6 +595,7 @@ class AnalyzerResult(MetadataObject): return self.audioMetadata.start + self.dataObject.time pass + @property def duration(self): if self.timeMode == 'global': return self.audioMetadata.duration @@ -605,6 +608,15 @@ class AnalyzerResult(MetadataObject): elif self.timeMode == 'segment': return self.dataObject.duration + @property + def id(self): + return self.idMetadata.id + + @property + def name(self): + return self.idMetadata.name + + # @property # def properties(self): @@ -879,6 +891,7 @@ class Analyzer(Processor): self.result_blocksize = self.input_blocksize self.result_stepsize = self.input_stepsize + @property def results(self): return AnalyzerResultContainer(