From: Thomas Fillon Date: Thu, 18 Dec 2014 15:53:00 +0000 (+0100) Subject: Fix bug in cdd971db06391a724f03 X-Git-Tag: 0.7^2~36^2 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=0be4006f92740127af828a817af5cbcf5a821561;p=timeside.git Fix bug in cdd971db06391a724f03 --- diff --git a/tests/test_graphers_render_analyzers.py b/tests/test_graphers_render_analyzers.py index d047a84..b013466 100755 --- a/tests/test_graphers_render_analyzers.py +++ b/tests/test_graphers_render_analyzers.py @@ -3,8 +3,7 @@ from __future__ import division from unit_timeside import unittest, TestRunner import timeside -from scipy.signal import chirp -import numpy as np +from timeside.tools.test_samples import samples from tempfile import NamedTemporaryFile import os @@ -15,13 +14,9 @@ class Test_graphers_analyzers(unittest.TestCase): """ test Graphers from analyzers""" def setUp(self): - samplerate = 16000 # LimsiSad require Fs = 16000 Hz - duration = 10 - t = np.arange(0, duration, 1/samplerate) - samples = chirp(t=t, f0=20, t1=t[-1], f1=samplerate/2, - method='logarithmic') - decoder_cls = timeside.core.get_processor('array_decoder') - self.decoder = decoder_cls(samples, samplerate=samplerate) + source = samples["C4_scale.wav"] + decoder_cls = timeside.core.get_processor('file_decoder') + self.decoder = decoder_cls(uri=source) def _perform_test(self, grapher_cls): """Internal function that test grapher for a given analyzer""" diff --git a/timeside/analyzer/core.py b/timeside/analyzer/core.py index 8e9483d..151d09b 100644 --- a/timeside/analyzer/core.py +++ b/timeside/analyzer/core.py @@ -834,9 +834,19 @@ class FrameValueObject(ValueObject, FramewiseObject): # see http://stackoverflow.com/a/8881973 # TODO: mean may not be appropriate for waveform ... (mean~=0) nb_frames = self.data.shape[0] - chunksize = size[0] - numchunks = nb_frames // chunksize + numchunks = size[0] + + if nb_frames > 10*numchunks: + ax.plot(self.time, self.data) + return + else: + chunksize = 1 + numchunks = nb_frames + + print "nb_frames %d" % nb_frames + print "chunksize %d" % chunksize + print "numchunks %d" % numchunks if self.data.ndim <= 1: ychunks = self.data[:chunksize*numchunks].reshape((-1, @@ -854,9 +864,9 @@ class FrameValueObject(ValueObject, FramewiseObject): xcenters = xchunks.mean(axis=1) # Now plot the bounds and the mean... - ax.fill_between(xcenters, min_env, max_env, color='gray', - edgecolor='none', alpha=0.5) - ax.plot(xcenters, ycenters) + ax.fill_between(xcenters, min_env, max_env, color='blue', + edgecolor='black', alpha=1) + #ax.plot(xcenters, ycenters, color='gray', alpha=0.5) #ax.plot(self.time, self.data) else: diff --git a/timeside/grapher/render_analyzers.py b/timeside/grapher/render_analyzers.py index 81dd586..125cb10 100644 --- a/timeside/grapher/render_analyzers.py +++ b/timeside/grapher/render_analyzers.py @@ -54,10 +54,10 @@ class DisplayAnalyzer(Grapher): @interfacedoc def post_process(self): pipe_result = self.process_pipe.results - parent_uuid = self.parents['analyzer'].uuid() - parent_result = pipe_result[parent_uuid][self._result_id] + analyzer_uuid = self.parents['analyzer'].uuid() + analyzer_result = pipe_result[analyzer_uuid][self._result_id] - fg_image = parent_result._render_PIL((self.image_width, + fg_image = analyzer_result._render_PIL((self.image_width, self.image_height), self.dpi) if self._background: bg_uuid = self.parents['bg_analyzer'].uuid() @@ -69,7 +69,7 @@ class DisplayAnalyzer(Grapher): # Merge background and foreground images from PIL.Image import blend - fg_image = blend(fg_image, bg_image, 0.25) + fg_image = blend(fg_image, bg_image, 0.15) self.image = fg_image @@ -107,8 +107,6 @@ class DisplayAnalyzer(Grapher): parent_analyzer = analyzer(**analyzer_parameters) self.parents['analyzer'] = parent_analyzer - # TODO : make it generic when analyzer will be "atomize" - self._parent_uuid = parent_analyzer.uuid() self._result_id = result_id @staticmethod